vortex_compute/take/vector/
primitive.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_dtype::UnsignedPType;
5use vortex_vector::VectorOps;
6use vortex_vector::match_each_pvector;
7use vortex_vector::primitive::PVector;
8use vortex_vector::primitive::PrimitiveVector;
9
10use crate::take::Take;
11
12impl<I: UnsignedPType> Take<PVector<I>> for &PrimitiveVector {
13    type Output = PrimitiveVector;
14
15    fn take(self, indices: &PVector<I>) -> PrimitiveVector {
16        // If all the indices are valid, we can delegate to the slice indices implementation.
17        if indices.validity().all_true() {
18            return self.take(indices.elements().as_slice());
19        }
20
21        match_each_pvector!(self, |v| { v.take(indices).into() })
22    }
23}
24
25impl<I: UnsignedPType> Take<[I]> for &PrimitiveVector {
26    type Output = PrimitiveVector;
27
28    fn take(self, indices: &[I]) -> PrimitiveVector {
29        match_each_pvector!(self, |v| { v.take(indices).into() })
30    }
31}