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


##########
cpp/src/arrow/compute/light_array.cc:
##########
@@ -575,18 +576,26 @@ Status ExecBatchBuilder::AppendSelected(const 
std::shared_ptr<ArrayData>& source
 
     // Step 1: calculate target offsets
     //
-    uint32_t* offsets = reinterpret_cast<uint32_t*>(target->mutable_data(1));
-    uint32_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
-    Visit(source, num_rows_to_append, row_ids,
-          [&](int i, const uint8_t* ptr, uint32_t num_bytes) {
-            offsets[num_rows_before + i] = num_bytes;
-          });
-    for (int i = 0; i < num_rows_to_append; ++i) {
-      uint32_t length = offsets[num_rows_before + i];
-      offsets[num_rows_before + i] = sum;
-      sum += length;
+    int32_t* offsets = reinterpret_cast<int32_t*>(target->mutable_data(1));
+    {
+      int64_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
+      Visit(source, num_rows_to_append, row_ids,
+            [&](int i, const uint8_t* ptr, uint32_t num_bytes) {
+              offsets[num_rows_before + i] = num_bytes;
+            });
+      for (int i = 0; i < num_rows_to_append; ++i) {
+        int32_t length = offsets[num_rows_before + i];
+        offsets[num_rows_before + i] = static_cast<int32_t>(sum);
+        if (ARROW_PREDICT_FALSE(sum + length > BinaryBuilder::memory_limit())) 
{

Review Comment:
   Good to know there is such handy functions!



##########
cpp/src/arrow/compute/light_array.cc:
##########
@@ -575,18 +576,26 @@ Status ExecBatchBuilder::AppendSelected(const 
std::shared_ptr<ArrayData>& source
 
     // Step 1: calculate target offsets
     //
-    uint32_t* offsets = reinterpret_cast<uint32_t*>(target->mutable_data(1));
-    uint32_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
-    Visit(source, num_rows_to_append, row_ids,
-          [&](int i, const uint8_t* ptr, uint32_t num_bytes) {
-            offsets[num_rows_before + i] = num_bytes;
-          });
-    for (int i = 0; i < num_rows_to_append; ++i) {
-      uint32_t length = offsets[num_rows_before + i];
-      offsets[num_rows_before + i] = sum;
-      sum += length;
+    int32_t* offsets = reinterpret_cast<int32_t*>(target->mutable_data(1));
+    {
+      int64_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
+      Visit(source, num_rows_to_append, row_ids,
+            [&](int i, const uint8_t* ptr, uint32_t num_bytes) {
+              offsets[num_rows_before + i] = num_bytes;
+            });
+      for (int i = 0; i < num_rows_to_append; ++i) {
+        int32_t length = offsets[num_rows_before + i];
+        offsets[num_rows_before + i] = static_cast<int32_t>(sum);
+        if (ARROW_PREDICT_FALSE(sum + length > BinaryBuilder::memory_limit())) 
{

Review Comment:
   Good to know there is such handy function!



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