Skip to content

Commit 3bef63b

Browse files
authored
feat: BoolArray::take is faster (#1035)
This is pretty minor, but after all the other DictArray take improvements land this will be one of the bigger time sinks.
1 parent bef0ae6 commit 3bef63b

File tree

1 file changed

+4
-4
lines changed
  • vortex-array/src/array/bool/compute

1 file changed

+4
-4
lines changed

vortex-array/src/array/bool/compute/take.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ impl TakeFn for BoolArray {
1212
let validity = self.validity();
1313
let indices = indices.clone().into_primitive()?;
1414
match_each_integer_ptype!(indices.ptype(), |$I| {
15-
Ok(BoolArray::from_vec(
15+
Ok(BoolArray::try_new(
1616
take_bool(&self.boolean_buffer(), indices.maybe_null_slice::<$I>()),
1717
validity.take(indices.as_ref())?,
18-
).into_array())
18+
)?.into_array())
1919
})
2020
}
2121
}
2222

23-
fn take_bool<I: AsPrimitive<usize>>(bools: &BooleanBuffer, indices: &[I]) -> Vec<bool> {
24-
indices.iter().map(|&idx| bools.value(idx.as_())).collect()
23+
fn take_bool<I: AsPrimitive<usize>>(bools: &BooleanBuffer, indices: &[I]) -> BooleanBuffer {
24+
BooleanBuffer::collect_bool(indices.len(), |idx| bools.value(indices[idx].as_()))
2525
}
2626

2727
#[cfg(test)]

0 commit comments

Comments
 (0)