Dandandan commented on code in PR #9755:
URL: https://github.com/apache/arrow-rs/pull/9755#discussion_r3104926222
##########
arrow-select/src/coalesce/primitive.rs:
##########
@@ -94,6 +97,94 @@ impl<T: ArrowPrimitiveType + Debug> InProgressArray for
InProgressPrimitiveArray
Ok(())
}
+ 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>();
+
+ match filter.strategy() {
+ IterationStrategy::None => return Ok(()),
+ IterationStrategy::All => return self.copy_rows(0, filter.count()),
+ IterationStrategy::Slices(slices) => {
+ for &(start, end) in slices {
+ self.copy_rows(start, end - start)?;
+ }
+ return Ok(());
+ }
+ IterationStrategy::SlicesIterator => {
+ for (start, end) in SlicesIterator::new(filter.filter_array())
{
+ self.copy_rows(start, end - start)?;
+ }
+ return Ok(());
+ }
+ IterationStrategy::Indices(_) | IterationStrategy::IndexIterator
=> {}
+ }
+
+ if let Some((null_count, nulls)) = filter_null_mask(s.nulls(), filter)
{
+ let nulls = unsafe {
+ NullBuffer::new_unchecked(BooleanBuffer::new(nulls, 0,
filter.count()), null_count)
+ };
+ self.nulls.append_buffer(&nulls);
+ } else {
+ self.nulls.append_n_non_nulls(filter.count());
+ }
+
+ let values = s.values();
+
+ match filter.strategy() {
+ IterationStrategy::Indices(indices) => {
+ self.current.extend(indices.iter().map(|&idx| values[idx]));
+ }
+ IterationStrategy::IndexIterator => {
+ self.current.extend(
+ IndexIterator::new(filter.filter_array(), filter.count())
+ .map(|idx| values[idx]),
+ );
+ }
+ IterationStrategy::None
+ | IterationStrategy::All
+ | IterationStrategy::Slices(_)
+ | IterationStrategy::SlicesIterator => unreachable!(),
+ }
+
+ Ok(())
+ }
+
+ fn copy_rows_by_indices(&mut self, indices: &[usize]) -> 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>();
+
+ if let Some(nulls) = s.nulls().filter(|nulls| nulls.null_count() > 0) {
+ for &idx in indices {
Review Comment:
I think there should be a path based on iterator here as well?
--
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]