wesm commented on a change in pull request #7410:
URL: https://github.com/apache/arrow/pull/7410#discussion_r439739768

File path: cpp/src/arrow/compute/kernels/scalar_validity.cc
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//   http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#include "arrow/compute/kernels/common.h"
+#include "arrow/util/bit_util.h"
+#include "arrow/util/bitmap_ops.h"
+namespace arrow {
+namespace compute {
+struct IsValid {
+  static void Call(KernelContext* ctx, const Scalar& in, Scalar* out) {
+    checked_cast<BooleanScalar*>(out)->value = in.is_valid;
+  }
+  static void Call(KernelContext* ctx, const ArrayData& arr, ArrayData* out) {
+    if (arr.buffers[0] != nullptr && out->offset == arr.offset &&
+        out->length == arr.length) {
+      out->buffers[1] = arr.buffers[0];
+      return;
+    }

Review comment:
       If you want to do a zero-copy optimization, you need to configure the 
kernel to use  `MemAllocation::COMPUTED_NO_PREALLOCATE`. This also makes it so 
you don't have to check the offset and length. You will however have to 
allocate memory when the zero copy path is not possible

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

Reply via email to