Copilot commented on code in PR #45001:
URL: https://github.com/apache/arrow/pull/45001#discussion_r3638692719


##########
cpp/src/arrow/compute/kernels/scalar_hash.cc:
##########
@@ -0,0 +1,240 @@
+// 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 <algorithm>
+
+#include "arrow/array/array_base.h"
+#include "arrow/array/builder_primitive.h"
+#include "arrow/compute/kernels/common_internal.h"
+#include "arrow/compute/key_hash_internal.h"
+#include "arrow/compute/light_array_internal.h"
+#include "arrow/compute/util.h"
+#include "arrow/result.h"
+
+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 {
+
+// ------------------------------
+// Kernel implementations
+// It is expected that HashArrowType is either UInt32Type or UInt64Type 
(default)
+
+template <typename ArrowType, typename Hasher>
+struct FastHashScalar {
+  using c_type = typename ArrowType::c_type;
+
+  static Result<KeyColumnArray> ToColumnArray(
+      const ArraySpan& array, LightContext* ctx,
+      const uint8_t* list_values_buffer = nullptr) {
+    KeyColumnMetadata metadata;
+    const uint8_t* validity_buffer = nullptr;
+    const uint8_t* fixed_length_buffer = nullptr;
+    const uint8_t* var_length_buffer = nullptr;
+
+    if (array.GetBuffer(0) != nullptr) {
+      validity_buffer = array.GetBuffer(0)->data();
+    }
+    if (array.GetBuffer(1) != nullptr) {
+      fixed_length_buffer = array.GetBuffer(1)->data();
+    }
+
+    auto type = array.type;
+    auto type_id = type->id();
+    if (type_id == Type::NA) {
+      metadata = KeyColumnMetadata(true, 0, true);
+    } else if (type_id == Type::BOOL) {
+      metadata = KeyColumnMetadata(true, 0);
+    } else if (is_fixed_width(type_id)) {
+      metadata = KeyColumnMetadata(true, type->bit_width() / 8);
+    } else if (is_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (is_large_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (type_id == Type::MAP) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LARGE_LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::FIXED_SIZE_LIST) {
+      auto list_type = checked_cast<const FixedSizeListType*>(type);
+      metadata = KeyColumnMetadata(true, list_type->list_size());
+      fixed_length_buffer = list_values_buffer;

Review Comment:
   `ToColumnArray()` doesn't handle dictionary-encoded inputs (even though 
dictionaries are hashable via `KeyColumnMetadata` elsewhere), and 
`FIXED_SIZE_LIST` uses `list_size()` as a byte length (it should be bytes per 
row). Both issues can lead to incorrect results or unexpected TypeError.



##########
cpp/src/arrow/compute/kernels/scalar_hash.cc:
##########
@@ -0,0 +1,240 @@
+// 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 <algorithm>
+
+#include "arrow/array/array_base.h"
+#include "arrow/array/builder_primitive.h"
+#include "arrow/compute/kernels/common_internal.h"
+#include "arrow/compute/key_hash_internal.h"
+#include "arrow/compute/light_array_internal.h"
+#include "arrow/compute/util.h"
+#include "arrow/result.h"
+
+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 {
+
+// ------------------------------
+// Kernel implementations
+// It is expected that HashArrowType is either UInt32Type or UInt64Type 
(default)
+
+template <typename ArrowType, typename Hasher>
+struct FastHashScalar {
+  using c_type = typename ArrowType::c_type;
+
+  static Result<KeyColumnArray> ToColumnArray(
+      const ArraySpan& array, LightContext* ctx,
+      const uint8_t* list_values_buffer = nullptr) {
+    KeyColumnMetadata metadata;
+    const uint8_t* validity_buffer = nullptr;
+    const uint8_t* fixed_length_buffer = nullptr;
+    const uint8_t* var_length_buffer = nullptr;
+
+    if (array.GetBuffer(0) != nullptr) {
+      validity_buffer = array.GetBuffer(0)->data();
+    }
+    if (array.GetBuffer(1) != nullptr) {
+      fixed_length_buffer = array.GetBuffer(1)->data();
+    }
+
+    auto type = array.type;
+    auto type_id = type->id();
+    if (type_id == Type::NA) {
+      metadata = KeyColumnMetadata(true, 0, true);
+    } else if (type_id == Type::BOOL) {
+      metadata = KeyColumnMetadata(true, 0);
+    } else if (is_fixed_width(type_id)) {
+      metadata = KeyColumnMetadata(true, type->bit_width() / 8);
+    } else if (is_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (is_large_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (type_id == Type::MAP) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LARGE_LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::FIXED_SIZE_LIST) {
+      auto list_type = checked_cast<const FixedSizeListType*>(type);
+      metadata = KeyColumnMetadata(true, list_type->list_size());
+      fixed_length_buffer = list_values_buffer;
+    } else {
+      return Status::TypeError("Unsupported column data type ", type->name(),
+                               " used with hash32/hash64 compute kernel");
+    }
+
+    return KeyColumnArray(metadata, array.length, validity_buffer, 
fixed_length_buffer,
+                          var_length_buffer);
+  }
+
+  static Result<std::shared_ptr<ArrayData>> HashChild(const ArraySpan& array,
+                                                      const ArraySpan& child,
+                                                      LightContext* hash_ctx,
+                                                      MemoryPool* memory_pool) 
{
+    auto arrow_type = TypeTraits<ArrowType>::type_singleton();
+    auto buffer_size = child.length * sizeof(c_type);
+    ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(buffer_size, 
memory_pool));
+    ARROW_RETURN_NOT_OK(
+        HashArray(child, hash_ctx, memory_pool, 
buffer->mutable_data_as<c_type>()));
+    return ArrayData::Make(arrow_type, child.length,
+                           {array.GetBuffer(0), std::move(buffer)}, 
array.null_count);

Review Comment:
   `HashChild()` builds an ArrayData for the child hashes using the *parent* 
validity buffer and null_count. This breaks null semantics (e.g. null struct 
fields no longer combine as NULL) and is also incorrect when the child length 
differs from the parent (e.g. list values).



##########
cpp/src/arrow/compute/kernels/scalar_hash_test.cc:
##########
@@ -0,0 +1,539 @@
+// 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 <gtest/gtest.h>
+#include <unordered_set>
+
+#include "arrow/chunked_array.h"
+#include "arrow/compute/api.h"
+#include "arrow/compute/kernels/test_util_internal.h"
+#include "arrow/compute/key_hash_internal.h"
+#include "arrow/compute/util.h"
+#include "arrow/result.h"
+#include "arrow/status.h"
+#include "arrow/testing/extension_type.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/matchers.h"
+#include "arrow/testing/random.h"
+#include "arrow/testing/util.h"
+#include "arrow/util/cpu_info.h"
+#include "arrow/util/key_value_metadata.h"
+
+namespace arrow {
+namespace compute {
+
+constexpr auto kSeed = 0x94378165;
+constexpr auto kArrayLengths = {0, 50, 100};
+constexpr auto kNullProbabilities = {0.0, 0.5, 1.0};
+
+class TestScalarHash : public ::testing::Test {
+ public:
+  template <typename c_type>
+  void AssertHashesEqual(const std::shared_ptr<Array>& arr, Datum res,
+                         std::vector<c_type> exp) {
+    auto res_array = res.array();
+    for (int64_t val_ndx = 0; val_ndx < arr->length(); ++val_ndx) {
+      c_type actual_hash = res_array->GetValues<c_type>(1)[val_ndx];
+      if (arr->IsNull(val_ndx)) {
+        ASSERT_EQ(0, actual_hash);
+      } else {
+        ASSERT_EQ(exp[val_ndx], actual_hash);
+      }
+    }
+  }
+
+  template <typename c_type>
+  std::vector<c_type> HashPrimitive(const std::shared_ptr<Array>& arr) {
+    std::vector<c_type> hashes(arr->length());
+    // Choose the Hasher type conditionally based on c_type
+
+    if constexpr (std::is_same_v<c_type, uint64_t>) {
+      Hashing64::HashFixed(false, static_cast<uint32_t>(arr->length()),
+                           arr->type()->bit_width() / 8,
+                           arr->data()->GetValues<uint8_t>(1), hashes.data());
+    } else {
+      
Hashing32::HashFixed(::arrow::internal::CpuInfo::GetInstance()->hardware_flags(),
+                           false, static_cast<uint32_t>(arr->length()),
+                           arr->type()->bit_width() / 8,
+                           arr->data()->GetValues<uint8_t>(1), hashes.data(), 
nullptr);
+    }
+
+    return hashes;
+  }
+
+  template <typename c_type>
+  std::vector<c_type> HashBinaryLike(const std::shared_ptr<Array>& arr) {
+    std::vector<c_type> hashes(arr->length());
+    auto length = static_cast<uint32_t>(arr->length());
+    auto values = arr->data()->GetValues<uint8_t>(2);
+    if constexpr (std::is_same_v<c_type, uint64_t>) {
+      if (arr->type_id() == Type::LARGE_BINARY || arr->type_id() == 
Type::LARGE_STRING) {
+        Hashing64::HashVarLen(false, length, 
arr->data()->GetValues<uint64_t>(1), values,
+                              hashes.data());
+      } else {
+        Hashing64::HashVarLen(false, length, 
arr->data()->GetValues<uint32_t>(1), values,
+                              hashes.data());
+      }
+    } else {
+      auto hw_flags = 
::arrow::internal::CpuInfo::GetInstance()->hardware_flags();
+      if (arr->type_id() == Type::LARGE_BINARY || arr->type_id() == 
Type::LARGE_STRING) {
+        Hashing32::HashVarLen(hw_flags, false, length,
+                              arr->data()->GetValues<uint64_t>(1), values, 
hashes.data(),
+                              nullptr);
+      } else {
+        Hashing32::HashVarLen(hw_flags, false, length,
+                              arr->data()->GetValues<uint32_t>(1), values, 
hashes.data(),
+                              nullptr);
+      }
+    }
+    return hashes;
+  }
+
+  void CheckDeterministic(const std::string& func, const 
std::shared_ptr<Array>& arr) {
+    // Check that the hash is deterministic between different runs
+    ASSERT_OK_AND_ASSIGN(Datum res1, CallFunction(func, {arr}));
+    ASSERT_OK_AND_ASSIGN(Datum res2, CallFunction(func, {arr}));
+    ValidateOutput(res1);
+    ValidateOutput(res2);
+    ASSERT_EQ(res1.length(), arr->length());
+    ASSERT_EQ(res2.length(), arr->length());
+    if (func == "hash64") {
+      ASSERT_EQ(res1.type()->id(), Type::UINT64);
+    } else if (func == "hash32") {
+      ASSERT_EQ(res1.type()->id(), Type::UINT32);
+    } else {
+      FAIL() << "Unknown function: " << func;
+    }
+    AssertDatumsEqual(res1, res2);
+
+    // Check that slicing the array does not affect the hash
+    auto hashes = res1.make_array();
+    if (arr->length() >= 1) {
+      auto in1 = arr->Slice(1);
+      ASSERT_OK_AND_ASSIGN(Datum out1, CallFunction(func, {in1}));
+      ValidateOutput(out1);
+      AssertArraysEqual(*out1.make_array(), *hashes->Slice(1));
+    } else if (arr->length() >= 4) {
+      auto in2 = arr->Slice(2, 2);
+      ASSERT_OK_AND_ASSIGN(Datum out2, CallFunction(func, {in2}));
+      ValidateOutput(out2);
+      AssertArraysEqual(*out2.make_array(), *hashes->Slice(2, 2));
+    }

Review Comment:
   The slicing check is currently unreachable for arrays with length >= 4 
because it is under an `else if` after `if (arr->length() >= 1)`. This means 
the intended second slicing scenario is never exercised.



##########
cpp/src/arrow/compute/kernels/scalar_hash.cc:
##########
@@ -0,0 +1,240 @@
+// 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 <algorithm>
+
+#include "arrow/array/array_base.h"
+#include "arrow/array/builder_primitive.h"
+#include "arrow/compute/kernels/common_internal.h"
+#include "arrow/compute/key_hash_internal.h"
+#include "arrow/compute/light_array_internal.h"
+#include "arrow/compute/util.h"
+#include "arrow/result.h"
+
+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 {
+
+// ------------------------------
+// Kernel implementations
+// It is expected that HashArrowType is either UInt32Type or UInt64Type 
(default)
+
+template <typename ArrowType, typename Hasher>
+struct FastHashScalar {
+  using c_type = typename ArrowType::c_type;
+
+  static Result<KeyColumnArray> ToColumnArray(
+      const ArraySpan& array, LightContext* ctx,
+      const uint8_t* list_values_buffer = nullptr) {
+    KeyColumnMetadata metadata;
+    const uint8_t* validity_buffer = nullptr;
+    const uint8_t* fixed_length_buffer = nullptr;
+    const uint8_t* var_length_buffer = nullptr;
+
+    if (array.GetBuffer(0) != nullptr) {
+      validity_buffer = array.GetBuffer(0)->data();
+    }
+    if (array.GetBuffer(1) != nullptr) {
+      fixed_length_buffer = array.GetBuffer(1)->data();
+    }
+
+    auto type = array.type;
+    auto type_id = type->id();
+    if (type_id == Type::NA) {
+      metadata = KeyColumnMetadata(true, 0, true);
+    } else if (type_id == Type::BOOL) {
+      metadata = KeyColumnMetadata(true, 0);
+    } else if (is_fixed_width(type_id)) {
+      metadata = KeyColumnMetadata(true, type->bit_width() / 8);
+    } else if (is_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (is_large_binary_like(type_id)) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = array.GetBuffer(2)->data();
+    } else if (type_id == Type::MAP) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint32_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::LARGE_LIST) {
+      metadata = KeyColumnMetadata(false, sizeof(uint64_t));
+      var_length_buffer = list_values_buffer;
+    } else if (type_id == Type::FIXED_SIZE_LIST) {
+      auto list_type = checked_cast<const FixedSizeListType*>(type);
+      metadata = KeyColumnMetadata(true, list_type->list_size());
+      fixed_length_buffer = list_values_buffer;
+    } else {
+      return Status::TypeError("Unsupported column data type ", type->name(),
+                               " used with hash32/hash64 compute kernel");
+    }
+
+    return KeyColumnArray(metadata, array.length, validity_buffer, 
fixed_length_buffer,
+                          var_length_buffer);
+  }
+
+  static Result<std::shared_ptr<ArrayData>> HashChild(const ArraySpan& array,
+                                                      const ArraySpan& child,
+                                                      LightContext* hash_ctx,
+                                                      MemoryPool* memory_pool) 
{
+    auto arrow_type = TypeTraits<ArrowType>::type_singleton();
+    auto buffer_size = child.length * sizeof(c_type);
+    ARROW_ASSIGN_OR_RAISE(auto buffer, AllocateBuffer(buffer_size, 
memory_pool));
+    ARROW_RETURN_NOT_OK(
+        HashArray(child, hash_ctx, memory_pool, 
buffer->mutable_data_as<c_type>()));
+    return ArrayData::Make(arrow_type, child.length,
+                           {array.GetBuffer(0), std::move(buffer)}, 
array.null_count);
+  }
+
+  static Status HashArray(const ArraySpan& array, LightContext* hash_ctx,
+                          MemoryPool* memory_pool, c_type* out) {
+    // KeyColumnArray objects are being passed to the hashing utility
+    KeyColumnArray column;
+    std::vector<KeyColumnArray> columns(1);
+
+    auto type_id = array.type->id();
+    if (type_id == Type::EXTENSION) {
+      auto extension_type = checked_cast<const ExtensionType*>(array.type);
+      auto storage_array = array;
+      storage_array.type = extension_type->storage_type().get();
+      return HashArray(storage_array, hash_ctx, memory_pool, out);
+    }
+
+    if (type_id == Type::STRUCT) {
+      std::vector<std::shared_ptr<ArrayData>> 
child_hashes(array.child_data.size());
+      columns.resize(array.child_data.size());
+      for (size_t i = 0; i < array.child_data.size(); i++) {
+        auto child = array.child_data[i];
+        if (is_nested(child.type->id())) {
+          ARROW_ASSIGN_OR_RAISE(child_hashes[i],
+                                HashChild(array, child, hash_ctx, 
memory_pool));
+          ARROW_ASSIGN_OR_RAISE(column, ToColumnArray(*child_hashes[i], 
hash_ctx));
+        } else {
+          ARROW_ASSIGN_OR_RAISE(column, ToColumnArray(child, hash_ctx));
+        }
+        columns[i] = column.Slice(array.offset, array.length);
+      }
+      Hasher::HashMultiColumn(columns, hash_ctx, out);

Review Comment:
   For `STRUCT`, the parent null bitmap is currently ignored when hashing 
non-nested children (child arrays are generated independently of the struct 
null bitmap). This can yield non-zero hashes for null struct rows. After 
hashing, explicitly zero out hashes for null struct rows.



##########
cpp/src/arrow/util/hashing_benchmark.cc:
##########
@@ -25,11 +25,21 @@
 #include "benchmark/benchmark.h"
 
 #include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
 #include "arrow/util/hashing.h"
 
+#include "arrow/array/builder_primitive.h"
+
 namespace arrow {
 namespace internal {
 
+namespace {
+// copied from scalar_string_benchmark
+constexpr auto kSeed = 0x94378165;
+
+static random::RandomArrayGenerator hashing_rng(kSeed);
+}  // namespace

Review Comment:
   `hashing_rng` (and its `kSeed`) are unused in this benchmark file, which can 
trigger `-Wunused-variable` warnings in some build configurations. Consider 
removing the unused generator (and associated includes) or using it to generate 
the benchmark inputs.



##########
cpp/src/arrow/compute/key_hash_benchmark.cc:
##########
@@ -0,0 +1,125 @@
+// 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 <algorithm>
+#include <cstdint>
+#include <limits>
+#include <random>
+#include <string>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/util/hashing.h"
+
+#include "arrow/array/builder_primitive.h"
+#include "arrow/compute/key_hash_internal.h"
+#include "arrow/compute/util_internal.h"
+
+namespace arrow {
+namespace internal {
+
+namespace {
+// copied from scalar_string_benchmark
+constexpr auto kSeed = 0x94378165;
+
+static random::RandomArrayGenerator hashing_rng(kSeed);
+}  // namespace
+
+static void KeyHashIntegers32(benchmark::State& state) {  // NOLINT non-const 
reference
+  auto test_vals = hashing_rng.Int32(10000, 0, 
std::numeric_limits<int32_t>::max());
+
+  // initialize the stack allocator
+  util::TempVectorStack stack_memallocator;
+  ASSERT_OK(
+      stack_memallocator.Init(compute::default_exec_context()->memory_pool(),
+                              3 * sizeof(int32_t) * 
util::MiniBatch::kMiniBatchLength));
+

Review Comment:
   The TempVectorStack capacity is hard-coded and doesn't match the documented 
`Hashing32::kHashBatchTempStackUsage` (and especially not 
`Hashing64::kHashBatchTempStackUsage`). If the stack is undersized this can 
lead to assertion failures or memory corruption during the benchmark.
   
   This issue also appears on line 86 of the same file.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to