pitrou commented on code in PR #45822:
URL: https://github.com/apache/arrow/pull/45822#discussion_r2010384450


##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -649,11 +726,29 @@ struct GrouperFastImpl : public Grouper {
       cols_[icol] = col_base.Slice(offset, num_rows);
     }
 
+    std::shared_ptr<arrow::Buffer> group_ids, null_bitmap;
+    // If we need to return the group ids, then allocate a buffer of group ids
+    // for all rows, otherwise each minibatch will reuse the same buffer.
+    const int64_t groups_ids_size =
+        (mode == GrouperMode::kPopulate) ? minibatch_size_max_ : num_rows;
+    ARROW_ASSIGN_OR_RAISE(group_ids, AllocateBuffer(sizeof(uint32_t) * 
groups_ids_size,
+                                                    ctx_->memory_pool()));
+    if (mode == GrouperMode::kLookup) {
+      ARROW_ASSIGN_OR_RAISE(null_bitmap,
+                            AllocateBitmap(groups_ids_size, 
ctx_->memory_pool()));
+    }
+
     // Split into smaller mini-batches
     //
     for (uint32_t start_row = 0; start_row < num_rows;) {
       uint32_t batch_size_next = 
std::min(static_cast<uint32_t>(minibatch_size_),
                                           static_cast<uint32_t>(num_rows) - 
start_row);
+      uint32_t* batch_group_ids = group_ids->mutable_data_as<uint32_t>() +
+                                  ((mode == GrouperMode::kPopulate) ? 0 : 
start_row);
+      if (mode == GrouperMode::kLookup) {
+        // Zero-initialize
+        memset(batch_group_ids, 0, batch_size_next * sizeof(uint32_t));
+      }

Review Comment:
   Indeed, done now!



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