ZhangHuiGui commented on code in PR #40484:
URL: https://github.com/apache/arrow/pull/40484#discussion_r1541422121
##########
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:
Yes, i've considered this. But the message has some detail numbers which
related with internal alloc size. This is not convenient for future maintenance
(for example, if some variables that require stack allocation are removed in
HashMultiColumn, this test will need to be modified).
--
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]