vortex_array/arrays/listview/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::{ListViewArray, ListViewVTable};
8use crate::compute::{MaskKernel, MaskKernelAdapter};
9use crate::vtable::ValidityHelper;
10use crate::{ArrayRef, IntoArray, register_kernel};
11
12impl MaskKernel for ListViewVTable {
13    fn mask(&self, array: &ListViewArray, mask: &Mask) -> VortexResult<ArrayRef> {
14        // SAFETY: Since we are only masking the validity and everything else comes from an already
15        // valid `ListViewArray`, all of the invariants are still upheld.
16        Ok(unsafe {
17            ListViewArray::new_unchecked(
18                array.elements().clone(),
19                array.offsets().clone(),
20                array.sizes().clone(),
21                array.validity().mask(mask),
22            )
23            .with_zero_copy_to_list(array.is_zero_copy_to_list())
24        }
25        .into_array())
26    }
27}
28
29register_kernel!(MaskKernelAdapter(ListViewVTable).lift());