zanmato1984 commented on code in PR #39383:
URL: https://github.com/apache/arrow/pull/39383#discussion_r1456365022


##########
cpp/src/arrow/compute/light_array_test.cc:
##########
@@ -407,6 +408,63 @@ TEST(ExecBatchBuilder, AppendValuesBeyondLimit) {
   ASSERT_EQ(0, pool->bytes_allocated());
 }
 
+TEST(ExecBatchBuilder, AppendVarLengthBeyondLimit) {
+  std::unique_ptr<MemoryPool> owned_pool = MemoryPool::CreateDefault();
+  MemoryPool* pool = owned_pool.get();
+  constexpr auto eight_mb = 8 * 1024 * 1024;
+  std::string str_8mb(eight_mb, 'a');
+  std::string str_8mb_minus_1(eight_mb - 1, 'b');
+  std::string str_8mb_minus_2(eight_mb - 2,
+                              'b');  // BaseBinaryBuilder::memory_limit()
+  std::shared_ptr<Array> values_8mb = ConstantArrayGenerator::String(1, 
str_8mb);
+  std::shared_ptr<Array> values_8mb_minus_1 =
+      ConstantArrayGenerator::String(1, str_8mb_minus_1);
+  std::shared_ptr<Array> values_8mb_minus_2 =
+      ConstantArrayGenerator::String(1, str_8mb_minus_2);
+
+  ExecBatch batch_8mb({values_8mb}, 1);
+  ExecBatch batch_8mb_minus_1({values_8mb_minus_1}, 1);
+  ExecBatch batch_8mb_minus_2({values_8mb_minus_2}, 1);
+
+  auto num_rows = std::numeric_limits<int32_t>::max() / eight_mb;
+  StringBuilder values_ref_builder;
+  ASSERT_OK(values_ref_builder.Reserve(num_rows + 1));
+  for (int i = 0; i < num_rows; i++) {
+    ASSERT_OK(values_ref_builder.Append(str_8mb));
+  }
+  ASSERT_OK(values_ref_builder.Append(str_8mb_minus_2));
+  ASSERT_OK_AND_ASSIGN(auto values_ref, values_ref_builder.Finish());
+  auto values_ref_1 = values_ref->Slice(0, num_rows);
+  ExecBatch batch_ref_1({values_ref_1}, num_rows);

Review Comment:
   Sorry, my bad. Thanks for pointing this out.



-- 
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

Reply via email to