js8544 commented on code in PR #35787: URL: https://github.com/apache/arrow/pull/35787#discussion_r1246045629
########## cpp/src/arrow/compute/kernels/vector_pairwise.cc: ########## @@ -0,0 +1,182 @@ +// 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. + +// Vector kernels for pairwise computation + +#include <iostream> +#include <memory> +#include "arrow/builder.h" +#include "arrow/compute/api_vector.h" +#include "arrow/compute/exec.h" +#include "arrow/compute/function.h" +#include "arrow/compute/kernel.h" +#include "arrow/compute/kernels/base_arithmetic_internal.h" +#include "arrow/compute/kernels/codegen_internal.h" +#include "arrow/compute/registry.h" +#include "arrow/compute/util.h" +#include "arrow/status.h" +#include "arrow/type.h" +#include "arrow/type_fwd.h" +#include "arrow/type_traits.h" +#include "arrow/util/bit_util.h" +#include "arrow/util/checked_cast.h" +#include "arrow/util/logging.h" +#include "arrow/visit_type_inline.h" + +namespace arrow::compute::internal { + +// We reuse the kernel exec function of a scalar binary function to compute pairwise +// results. For example, for pairwise_diff, we reuse subtract's kernel exec. +struct PairwiseState : KernelState { + PairwiseState(const PairwiseOptions& options, const ArrayKernelExec& scalar_exec) + : periods(options.periods), scalar_exec(scalar_exec) {} + + int64_t periods; + const ArrayKernelExec& scalar_exec; +}; + +KernelInit GeneratePairwiseInit(const ArrayKernelExec& scalar_exec) { + return [&scalar_exec](KernelContext* ctx, const KernelInitArgs& args) { Review Comment: Updated to inline lambda and capturing by value. -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org