Skip to main content

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;
5
6use crate::ArrayRef;
7use crate::IntoArray;
8use crate::arrays::StructArray;
9use crate::arrays::StructVTable;
10use crate::compute::MaskReduce;
11use crate::validity::Validity;
12use crate::vtable::ValidityHelper;
13
14impl MaskReduce for StructVTable {
15    fn mask(array: &StructArray, mask: &ArrayRef) -> VortexResult<Option<ArrayRef>> {
16        StructArray::try_new_with_dtype(
17            array.unmasked_fields().clone(),
18            array.struct_fields().clone(),
19            array.len(),
20            array
21                .validity()
22                .clone()
23                .and(Validity::Array(mask.clone()))?,
24        )
25        .map(|a| Some(a.into_array()))
26    }
27}