andygrove commented on issue #5944:
URL: https://github.com/apache/datafusion/issues/5944#issuecomment-2260794953
I did some research / prototyping on this idea.
I used this logic to create a selection vector from a predicate bit mask:
```rust
let num_true = predicate.true_count();
let mut b = Int32Builder::with_capacity(num_true);
for i in 0..predicate.len() {
if predicate.value(i) {
b.append_value(i as i32);
}
}
let offsets = b.finish();
```
The selection vector can then be used in a naive sum aggregate like this:
```rust
let mut sum = 0;
for i in 0..selection_vector.len() {
sum += array.value(selection_vector.value(i) as usize);
}
```
If we ignore the cost of creating the selection vector, then this approach
is faster than filtering the batch first. However, the cost of creating the
selection vector is similar to filtering a batch in some cases, such as when we
are aggregating a single column.
I'm less excited about using selection vectors for aggregates at this point.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]