vortex_array/arrays/masked/vtable/
operator.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_compute::mask::MaskValidity;
5use vortex_error::VortexResult;
6
7use crate::ArrayRef;
8use crate::arrays::{MaskedArray, MaskedVTable};
9use crate::execution::{BatchKernelRef, BindCtx, kernel};
10use crate::vtable::OperatorVTable;
11
12impl OperatorVTable<MaskedVTable> for MaskedVTable {
13    fn bind(
14        array: &MaskedArray,
15        selection: Option<&ArrayRef>,
16        ctx: &mut dyn BindCtx,
17    ) -> VortexResult<BatchKernelRef> {
18        // A masked array performs the intersection of the mask validity with the child validity.
19        let mask = ctx.bind_validity(&array.validity, array.len(), selection)?;
20        let child = ctx.bind(&array.child, selection)?;
21
22        Ok(kernel(move || {
23            let mask = mask.execute()?;
24            let child = child.execute()?;
25            Ok(MaskValidity::mask_validity(child, &mask))
26        }))
27    }
28}