Skip to main content

vortex_array/arrays/extension/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::ExtensionArray;
9use crate::arrays::ExtensionVTable;
10use crate::arrays::ScalarFnArrayExt;
11use crate::compute::MaskReduce;
12use crate::expr::EmptyOptions;
13use crate::expr::mask::Mask as MaskExpr;
14
15impl MaskReduce for ExtensionVTable {
16    fn mask(array: &ExtensionArray, mask: &ArrayRef) -> VortexResult<Option<ArrayRef>> {
17        let masked_storage = MaskExpr.try_new_array(
18            array.storage().len(),
19            EmptyOptions,
20            [array.storage().clone(), mask.clone()],
21        )?;
22        Ok(Some(
23            ExtensionArray::new(
24                array
25                    .ext_dtype()
26                    .with_nullability(masked_storage.dtype().nullability()),
27                masked_storage,
28            )
29            .into_array(),
30        ))
31    }
32}