bkietz commented on a change in pull request #7410: URL: https://github.com/apache/arrow/pull/7410#discussion_r441019388
########## File path: cpp/src/arrow/compute/kernels/scalar_validity.cc ########## @@ -0,0 +1,110 @@ +// 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 +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// 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 { + +using internal::CopyBitmap; +using internal::InvertBitmap; + +namespace compute { +namespace { + +struct IsValidOperator { + 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) { Review comment: As it happens this fails for sliced input. I'll restore the checks. For your interest, one approach i tried for `is_valid` was a `MetaFunction` which invoked a no-op ScalarFunction with INTERSECTION null handling then yanked the null bitmap from that. Unfortunately INTERSECTION doesn't currently support the zero copy case and I wasn't sure the approach would be acceptable but it did avoid repetition of null bitmap handling logic. What do you think? ---------------------------------------------------------------- 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: us...@infra.apache.org