raulcd commented on code in PR #46261: URL: https://github.com/apache/arrow/pull/46261#discussion_r2102319282
########## cpp/src/arrow/compute/kernels/registry.cc: ########## @@ -0,0 +1,94 @@ +// 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/registry.h" +#include "arrow/compute/kernels/registry.h" + +#include <algorithm> +#include <memory> +#include <mutex> +#include <unordered_map> +#include <utility> + +#include "arrow/compute/function.h" +#include "arrow/compute/function_internal.h" +#include "arrow/compute/registry_internal.h" +#include "arrow/status.h" +#include "arrow/util/config.h" // For ARROW_COMPUTE +#include "arrow/util/logging.h" + +namespace arrow::compute { +namespace internal { + +Status RegisterComputeKernels() { + auto registry = GetFunctionRegistry(); + + // Check if a compute kernels function is already registered + // to avoid multiple registration attempts. + auto func = registry->GetFunction("rank"); + if (func.ok()) { + return Status::OK(); + } + + // Register additional kernels on libarrow_compute + // Scalar functions + internal::RegisterScalarArithmetic(registry); + internal::RegisterScalarBoolean(registry); + internal::RegisterScalarComparison(registry); + internal::RegisterScalarIfElse(registry); + internal::RegisterScalarNested(registry); + internal::RegisterScalarRandom(registry); // Nullary + internal::RegisterScalarRoundArithmetic(registry); + internal::RegisterScalarSetLookup(registry); + internal::RegisterScalarStringAscii(registry); + internal::RegisterScalarStringUtf8(registry); + internal::RegisterScalarTemporalBinary(registry); + internal::RegisterScalarTemporalUnary(registry); + internal::RegisterScalarValidity(registry); + + // Vector functions + internal::RegisterVectorArraySort(registry); + internal::RegisterVectorCumulativeSum(registry); + internal::RegisterVectorNested(registry); + internal::RegisterVectorRank(registry); + internal::RegisterVectorReplace(registry); + internal::RegisterVectorSelectK(registry); + internal::RegisterVectorSort(registry); + internal::RegisterVectorRunEndEncode(registry); + internal::RegisterVectorRunEndDecode(registry); + internal::RegisterVectorPairwise(registry); + internal::RegisterVectorStatistics(registry); + internal::RegisterVectorSwizzle(registry); + + // Aggregate functions + internal::RegisterHashAggregateBasic(registry); + internal::RegisterHashAggregateNumeric(registry); + internal::RegisterHashAggregatePivot(registry); + internal::RegisterScalarAggregateBasic(registry); + internal::RegisterScalarAggregateMode(registry); + internal::RegisterScalarAggregatePivot(registry); + internal::RegisterScalarAggregateQuantile(registry); + internal::RegisterScalarAggregateTDigest(registry); + internal::RegisterScalarAggregateVariance(registry); + + return Status::OK(); +} + +} // namespace internal + +Status Initialize() { return internal::RegisterComputeKernels(); } Review Comment: Thanks, I've learnt something about static locals, initialization on first use and thread safety with those comments -- 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