Copilot commented on code in PR #50629:
URL: https://github.com/apache/arrow/pull/50629#discussion_r4335268461


##########
cpp/src/arrow/util/rle_bitmap_internal.h:
##########
@@ -229,6 +242,19 @@ class BitPackedRunToBitmapDecoder {
     return n_vals;
   }
 
+  /// Advance and count the number of occurrences of `value`.
+  ///
+  /// The count is limited to at most the next `batch_size` items.
+  /// @return The matching value count and number of elements that were 
processed.
+  RleCountUpToResult CountUpTo(bool value, rle_size_t batch_size) {
+    const auto n_vals = GetAdvanceCapacity(batch_size);
+    const auto set_count = 
static_cast<rle_size_t>(arrow::internal::CountSetBits(
+        unread_values_ptr(), unread_values_bit_offset(), n_vals));

Review Comment:
   `PageLevelDecoder::CountUpTo` can reach this implementation with an 
empty/exhausted bit-packed decoder, but this path still evaluates 
`unread_values_ptr()` before counting. That performs pointer arithmetic on a 
null `data_` pointer for the default decoder (and also violates the zero-item 
no-op behavior); return an empty result before accessing the bitmap when there 
is no batch or no remaining data.



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