vortex_array/arrays/struct_/compute/
mask.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::VortexResult;
5use vortex_mask::Mask;
6
7use crate::arrays::{StructArray, StructVTable};
8use crate::compute::{MaskKernel, MaskKernelAdapter};
9use crate::vtable::ValidityHelper;
10use crate::{ArrayRef, IntoArray, register_kernel};
11
12impl MaskKernel for StructVTable {
13    fn mask(&self, array: &StructArray, filter_mask: &Mask) -> VortexResult<ArrayRef> {
14        let validity = array.validity().mask(filter_mask)?;
15
16        StructArray::try_new_with_dtype(
17            array.fields().to_vec(),
18            array.struct_fields().clone(),
19            array.len(),
20            validity,
21        )
22        .map(|a| a.into_array())
23    }
24}
25register_kernel!(MaskKernelAdapter(StructVTable).lift());