fabianmurariu commented on code in PR #5573:
URL: https://github.com/apache/arrow-rs/pull/5573#discussion_r1545678230
##########
arrow-select/src/filter.rs:
##########
@@ -368,6 +375,43 @@ fn filter_array(values: &dyn Array, predicate:
&FilterPredicate) -> Result<Array
}
}
+/// Filter a [`RunArray`] based on a [`FilterPredicate`]
+fn filter_run_end_array(
+ re_arr: &RunArray<Int64Type>,
+ pred: &FilterPredicate,
+) -> Result<RunArray<Int64Type>, ArrowError> {
+ let run_ends: &RunEndBuffer<i64> = re_arr.run_ends();
+ let mut values_filter = BooleanBufferBuilder::new(run_ends.len());
+ let mut new_run_ends = vec![0i64; run_ends.len()];
+
+ let mut start = 0i64;
+ let mut i = 0;
+ let filter_values = pred.filter.values();
+ let mut count = 0;
+ for end in run_ends.inner() {
+ let mut keep = false;
+ for pred in (start..*end).map(|i| unsafe {
filter_values.value_unchecked(i as usize) }) {
+ count += pred as i64;
+ keep |= pred
+ }
+ new_run_ends[i] = count;
+ i += keep as usize;
+ values_filter.append(keep);
+ start = *end;
+ }
+
+ new_run_ends.truncate(i);
+
+ if values_filter.is_empty() {
+ new_run_ends.clear();
+ }
Review Comment:
I'm using this trick
```rust
new_run_ends[i] = count;
i += keep as usize;
```
to make it branchless, I can't do the same thing with push
--
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]