vortex_array/arrays/chunked/compute/
invert.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use itertools::Itertools;
5use vortex_error::VortexResult;
6
7use crate::ArrayRef;
8use crate::IntoArray;
9use crate::arrays::ChunkedArray;
10use crate::arrays::ChunkedVTable;
11use crate::compute::InvertKernel;
12use crate::compute::InvertKernelAdapter;
13use crate::compute::invert;
14use crate::register_kernel;
15
16impl InvertKernel for ChunkedVTable {
17    fn invert(&self, array: &ChunkedArray) -> VortexResult<ArrayRef> {
18        let chunks = array.chunks().iter().map(|c| invert(c)).try_collect()?;
19        // SAFETY: Invert operation preserves the dtype of each chunk.
20        // All inverted chunks maintain the same dtype as the original array.
21        unsafe { Ok(ChunkedArray::new_unchecked(chunks, array.dtype().clone()).into_array()) }
22    }
23}
24
25register_kernel!(InvertKernelAdapter(ChunkedVTable).lift());