neilconway commented on code in PR #11206:
URL: https://github.com/apache/arrow-rs/pull/11206#discussion_r4124409938


##########
arrow-select/src/coalesce.rs:
##########
@@ -262,7 +262,33 @@ impl BatchCoalescer {
         batch: RecordBatch,
         filter: &BooleanArray,
     ) -> Result<(), ArrowError> {
-        self.push_batch_with_filtered_columns(batch, filter)
+        // SAFETY: the count is computed from `filter` itself.
+        unsafe { self.push_batch_with_filter_and_count(batch, filter, 
filter.true_count()) }
+    }
+
+    /// Push a batch into the Coalescer after applying a filter whose number of
+    /// selected rows is already known.
+    ///
+    /// This is [`Self::push_batch_with_filter`] without the count of `filter`
+    /// it performs first. Callers that already track how many rows a filter
+    /// selects, for example to enforce a row limit, can pass that number here.
+    ///
+    /// # Safety
+    ///
+    /// `selected_count` must equal [`BooleanArray::true_count`] of `filter`. 
It
+    /// sizes the copied rows; see [`FilterBuilder::new_with_count`].
+    pub unsafe fn push_batch_with_filter_and_count(

Review Comment:
   Alright, I took a shot at this and updated the PR -- let me know what you 
think.



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