drin commented on code in PR #13487: URL: https://github.com/apache/arrow/pull/13487#discussion_r926054959
########## cpp/src/arrow/compute/kernels/scalar_hash.cc: ########## @@ -0,0 +1,194 @@ +// 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. + +/** + * @file scalar_hash.cc + * @brief Element-wise (scalar) kernels for hashing values. + */ + +#include <algorithm> +#include <iostream> + +#include "arrow/array/array_base.h" +#include "arrow/array/builder_primitive.h" +#include "arrow/compute/exec/key_hash.h" +#include "arrow/compute/exec/util.h" +#include "arrow/compute/kernels/common.h" +#include "arrow/compute/light_array.h" +#include "arrow/result.h" + +// NOTES: +// * `KeyColumnArray` comes from light_array.h +// * Should be replaceable with `ExecSpan` + +namespace arrow { +namespace compute { +namespace internal { + +// Define symbols visible within `arrow::compute::internal` in this file; +// these symbols are not visible outside of this file. +namespace { + +// ------------------------------ +// Function documentation +const FunctionDoc fast_hash_32_doc{ + "Construct a hash for every element of the input argument", + ("An element-wise function that uses an xxHash-like algorithm.\n" + "This function is not suitable for cryptographic purposes.\n" + "Hash results are 32-bit and emitted for each valid row.\n" + "Null (or invalid) rows emit a null in the output."), + {"hash_input"}}; + +const FunctionDoc fast_hash_64_doc{ + "Construct a hash for every element of the input argument", + ("An element-wise function that uses an xxHash-like algorithm.\n" + "This function is not suitable for cryptographic purposes.\n" + "Hash results are 64-bit and emitted for each valid row.\n" + "Null (or invalid) rows emit a null in the output."), + {"hash_input"}}; + +// ------------------------------ +// Kernel implementations +struct FastHash32Scalar { + static Status Exec(KernelContext* ctx, const ExecSpan& input_arg, ExecResult* out) { + if (input_arg.num_values() != 1 or not input_arg[0].is_array()) { + return Status::Invalid("FastHash32 currently supports a single array input"); + } + + // Initialize stack-based memory allocator with an allocator and memory size + util::TempVectorStack stack_memallocator; + ARROW_RETURN_NOT_OK(stack_memallocator.Init(ctx->exec_context()->memory_pool(), Review Comment: I didn't think so but I can guard against it -- 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