alamb commented on code in PR #8951:
URL: https://github.com/apache/arrow-rs/pull/8951#discussion_r2698481846
##########
arrow-buffer/src/builder/null.rs:
##########
@@ -412,4 +439,47 @@ mod tests {
assert_eq!(builder.finish(), None);
}
+
+ #[test]
+ fn test_extend() {
Review Comment:
this is fine to have, but technically speaking should these paths be covered
in the lower BooleanBufferBuilder::extend_trusted_len ?
##########
arrow-select/src/coalesce/primitive.rs:
##########
@@ -92,6 +93,145 @@ impl<T: ArrowPrimitiveType + Debug> InProgressArray for
InProgressPrimitiveArray
Ok(())
}
+ /// Copy rows using a predicate
+ fn copy_rows_by_filter(&mut self, filter: &FilterPredicate) -> Result<(),
ArrowError> {
+ self.ensure_capacity();
+
+ let s = self
+ .source
+ .as_ref()
+ .ok_or_else(|| {
+ ArrowError::InvalidArgumentError(
+ "Internal Error: InProgressPrimitiveArray: source not
set".to_string(),
+ )
+ })?
+ .as_primitive::<T>();
+
+ let values = s.values();
+ let count = filter.count();
+
+ // Use the predicate's strategy for optimal iteration
+ match filter.strategy() {
+ IterationStrategy::SlicesIterator => {
+ // Copy values, nulls using slices
+ if let Some(nulls) = s.nulls().filter(|n| n.null_count() > 0) {
+ for (start, end) in
SlicesIterator::new(filter.filter_array()) {
+ // SAFETY: slices are derived from filter predicate
+ self.current
+ .extend_from_slice(unsafe {
values.get_unchecked(start..end) });
+ let slice = nulls.slice(start, end - start);
+ self.nulls.append_buffer(&slice);
+ }
+ } else {
+ for (start, end) in
SlicesIterator::new(filter.filter_array()) {
+ // SAFETY: SlicesIterator produces valid ranges
derived from filter
+ self.current
+ .extend_from_slice(unsafe {
values.get_unchecked(start..end) });
+ }
+ self.nulls.append_n_non_nulls(count);
+ }
+ }
+ IterationStrategy::Slices(slices) => {
Review Comment:
This code still needs tests (it is still uncovered I think)
I can try and help find time to write some given how exciting this PR is
##########
arrow-buffer/src/builder/null.rs:
##########
@@ -412,4 +439,47 @@ mod tests {
assert_eq!(builder.finish(), None);
}
+
+ #[test]
+ fn test_extend() {
Review Comment:
e.g. these tests:
https://github.com/apache/arrow-rs/blob/840653bc0b1f072c6526aebce09fabbf4d938ce2/arrow-buffer/src/builder/boolean.rs#L580-L579
##########
arrow-select/src/coalesce/primitive.rs:
##########
@@ -95,6 +96,145 @@ impl<T: ArrowPrimitiveType + Debug> InProgressArray for
InProgressPrimitiveArray
Ok(())
}
+ /// Copy rows using a predicate
Review Comment:
That is a good point -- perhaps we can consolidate the implementations as a
follow on PR
What I was basically observing is that the specialized filtering iteration
was needed in Coalesce -- but it was currently bound tp FilterPredicate.
Figuring out how to reuse it was the trick.
--
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]