vortex_array/arrays/bool/vtable/
operator.rs1use vortex_compute::filter::Filter;
5use vortex_error::VortexResult;
6use vortex_vector::bool::BoolVector;
7
8use crate::arrays::{BoolArray, BoolVTable, MaskedVTable};
9use crate::execution::{BatchKernelRef, BindCtx, kernel};
10use crate::vtable::{OperatorVTable, ValidityHelper};
11use crate::{ArrayRef, IntoArray};
12
13impl OperatorVTable<BoolVTable> for BoolVTable {
14 fn bind(
15 array: &BoolArray,
16 selection: Option<&ArrayRef>,
17 ctx: &mut dyn BindCtx,
18 ) -> VortexResult<BatchKernelRef> {
19 let bits = array.buffer.clone();
20 let mask = ctx.bind_selection(array.len(), selection)?;
21 let validity = ctx.bind_validity(array.validity(), array.len(), selection)?;
22
23 Ok(kernel(move || {
24 let mask = mask.execute()?;
25 let validity = validity.execute()?;
26
27 let bits = bits.filter(&mask);
29
30 Ok(BoolVector::try_new(bits, validity)?.into())
31 }))
32 }
33
34 fn reduce_parent(
35 array: &BoolArray,
36 parent: &ArrayRef,
37 _child_idx: usize,
38 ) -> VortexResult<Option<ArrayRef>> {
39 if let Some(masked) = parent.as_opt::<MaskedVTable>() {
41 return Ok(Some(
42 BoolArray::from_bit_buffer(
43 array.bit_buffer().clone(),
44 array.validity().clone().and(masked.validity().clone()),
45 )
46 .into_array(),
47 ));
48 }
49
50 Ok(None)
51 }
52}