alamb commented on code in PR #8991:
URL: https://github.com/apache/arrow-rs/pull/8991#discussion_r2617186674
##########
arrow-select/src/coalesce.rs:
##########
@@ -243,6 +244,39 @@ impl BatchCoalescer {
self.push_batch(filtered_batch)
}
+ /// Push a batch into the Coalescer after applying a set of indices
+ /// This is semantically equivalent of calling [`Self::push_batch`]
+ /// with the results from [`take_record_batch`]
+ ///
+ /// # Example
+ /// ```
+ /// # use arrow_array::{record_batch, UInt64Array};
+ /// # use arrow_select::coalesce::BatchCoalescer;
+ /// let batch1 = record_batch!(("a", Int32, [0, 0, 0])).unwrap();
+ /// let batch2 = record_batch!(("a", Int32, [1, 1, 4, 5, 1, 4])).unwrap();
+ /// // Sorted indices to create a sorted output, this can be obtained with
+ /// // `arrow-ord`'s sort_to_indices operation
+ /// let indices = UInt64Array::from(vec![0, 1, 4, 2, 5, 3]);
+ /// // create a new Coalescer that targets creating 1000 row batches
+ /// let mut coalescer = BatchCoalescer::new(batch1.schema(), 1000);
+ /// coalescer.push_batch(batch1);
+ /// coalescer.push_batch_with_indices(batch2, &indices);
+ /// // finsh and retrieve the created batch
+ /// coalescer.finish_buffered_batch().unwrap();
+ /// let completed_batch = coalescer.next_completed_batch().unwrap();
+ /// let expected_batch = record_batch!(("a", Int32, [0, 0, 0, 1, 1, 1, 4,
4, 5])).unwrap();
+ /// assert_eq!(completed_batch, expected_batch);
+ /// ```
+ pub fn push_batch_with_indices(
+ &mut self,
+ batch: RecordBatch,
+ indices: &dyn Array,
+ ) -> Result<(), ArrowError> {
+ // todo: optimize this to avoid materializing (copying the results of
take indices to a new batch)
Review Comment:
👍
--
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]