jorgecarleitao edited a comment on pull request #8740:
URL: https://github.com/apache/arrow/pull/8740#issuecomment-731845713
Cool!
IMO we want to "take" from different arrays depending on a set of boolean
conditions. My recommendation is to use `MutableDataArray` API that we also
use in the Join and that was though through exactly for this use-case.
Something like
```rust
let boolean_conditions: Vec<BooleanArray> = <args>
let first_non_null: Vec<usize> = first_true(boolean_conditions) // index
from 0 to boolean_conditions.len() (inclusive, last represents the "else")
let capacity = boolean_conditions[0].len();
let arrays_data = arrays.iter().map(|array|
array.data_ref()).collect::<Vec<_>>();
let mutable = MutableDataArray::new(&arrays_data, capacity);
for row in boolean_conditions[0].len() {
let index = first_non_null[row];
if index == boolean_conditions.len() {
// the else case
mutable.extend_null(index); // this function is still not available
in master, but I have a branch with it
} else {
// take the slice `[row,row+1[` from array "index".
mutable.extend_from_slice(index, row, row + 1);
}
}
return make_array(Arc::new(mutable.freeze()));
```
the advantage of this is that it works for all types except struct.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]