zanmato1984 commented on code in PR #40484:
URL: https://github.com/apache/arrow/pull/40484#discussion_r1541508137
##########
cpp/src/arrow/compute/key_hash_test.cc:
##########
@@ -311,5 +311,38 @@ TEST(VectorHash, FixedLengthTailByteSafety) {
HashFixedLengthFrom(/*key_length=*/19, /*num_rows=*/64, /*start_row=*/63);
}
+TEST(HashBatch, AllocTempStackAsNeeded) {
+ auto arr = arrow::ArrayFromJSON(arrow::int32(), "[9,2,6]");
+ const auto batch_size = static_cast<int32_t>(arr->length());
+ arrow::compute::ExecBatch exec_batch({arr}, batch_size);
+ auto ctx = arrow::compute::default_exec_context();
+ std::vector<arrow::compute::KeyColumnArray> temp_column_arrays;
+
+ // alloc stack by HashBatch internal
+ std::vector<uint32_t> h1(batch_size);
+ ASSERT_OK(arrow::compute::Hashing32::HashBatch(
+ exec_batch, h1.data(), temp_column_arrays,
ctx->cpu_info()->hardware_flags(),
+ nullptr, 0, batch_size));
+
+ util::TempVectorStack stack;
+ std::vector<uint32_t> h2(batch_size);
+
+ // alloc stack overflow in HashBatch
+ ASSERT_OK(stack.Init(default_memory_pool(), batch_size));
+ ASSERT_NOT_OK(arrow::compute::Hashing32::HashBatch(
Review Comment:
Yeah, you are right. Thanks.
--
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]