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


##########
cpp/src/arrow/compute/row/grouper.cc:
##########
@@ -672,28 +772,38 @@ struct GrouperFastImpl : public Grouper {
                           match_bitvector.mutable_data(), 
local_slots.mutable_data());
         map_.find(batch_size_next, minibatch_hashes_.data(),
                   match_bitvector.mutable_data(), local_slots.mutable_data(),
-                  reinterpret_cast<uint32_t*>(group_ids->mutable_data()) + 
start_row,
-                  &temp_stack_, map_equal_impl_, nullptr);
+                  batch_group_ids, &temp_stack_, map_equal_impl_, nullptr);
+      }
+      if (mode == GrouperMode::kLookup) {
+        // Fill validity bitmap from match_bitvector
+        ::arrow::internal::CopyBitmap(match_bitvector.mutable_data(), 
/*offset=*/0,
+                                      /*length=*/batch_size_next,
+                                      null_bitmap->mutable_data(),
+                                      /*dest_offset=*/start_row);
+      } else {
+        // Insert new keys
+        auto ids = util::TempVectorHolder<uint16_t>(&temp_stack_, 
batch_size_next);
+        int num_ids;
+        util::bit_util::bits_to_indexes(0, encode_ctx_.hardware_flags, 
batch_size_next,
+                                        match_bitvector.mutable_data(), 
&num_ids,
+                                        ids.mutable_data());
+
+        RETURN_NOT_OK(map_.map_new_keys(
+            num_ids, ids.mutable_data(), minibatch_hashes_.data(), 
batch_group_ids,
+            &temp_stack_, map_equal_impl_, map_append_impl_, nullptr));
       }
-      auto ids = util::TempVectorHolder<uint16_t>(&temp_stack_, 
batch_size_next);
-      int num_ids;
-      util::bit_util::bits_to_indexes(0, encode_ctx_.hardware_flags, 
batch_size_next,
-                                      match_bitvector.mutable_data(), &num_ids,
-                                      ids.mutable_data());
-
-      RETURN_NOT_OK(map_.map_new_keys(
-          num_ids, ids.mutable_data(), minibatch_hashes_.data(),
-          reinterpret_cast<uint32_t*>(group_ids->mutable_data()) + start_row,
-          &temp_stack_, map_equal_impl_, map_append_impl_, nullptr));
 
       start_row += batch_size_next;
-
-      if (minibatch_size_ * 2 <= minibatch_size_max_) {
-        minibatch_size_ *= 2;
-      }
+      // XXX why not use minibatch_size_max_ from the start?
+      minibatch_size_ = std::min(minibatch_size_max_, 2 * minibatch_size_);

Review Comment:
   @zanmato1984 Would you know the answer to this XXX?



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