Skip to main content

vortex_array/arrays/decimal/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::array::ArrayView;
9use crate::arrays::Decimal;
10use crate::arrays::DecimalArray;
11use crate::scalar_fn::fns::mask::MaskReduce;
12use crate::validity::Validity;
13
14impl MaskReduce for Decimal {
15    const VALIDITY_IS_METADATA_ONLY: bool = true;
16
17    fn mask(array: ArrayView<'_, Decimal>, mask: &ArrayRef) -> VortexResult<Option<ArrayRef>> {
18        // SAFETY: the values and decimal type are unchanged, and masking only removes valid rows.
19        Ok(Some(unsafe {
20            DecimalArray::new_unchecked_handle(
21                array.buffer_handle().clone(),
22                array.values_type(),
23                array.decimal_dtype(),
24                array.validity()?.and(Validity::Array(mask.clone()))?,
25            )
26            .into_array()
27        }))
28    }
29}