vortex_compute/take/vector/
decimal.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::decimal::DecimalVector;
7use vortex_vector::match_each_dvector;
8use vortex_vector::primitive::PVector;
9
10use crate::take::Take;
11
12impl<I: UnsignedPType> Take<PVector<I>> for &DecimalVector {
13    type Output = DecimalVector;
14
15    fn take(self, indices: &PVector<I>) -> DecimalVector {
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_dvector!(self, |v| { v.take(indices).into() })
22    }
23}
24
25impl<I: UnsignedPType> Take<[I]> for &DecimalVector {
26    type Output = DecimalVector;
27
28    fn take(self, indices: &[I]) -> DecimalVector {
29        match_each_dvector!(self, |v| { v.take(indices).into() })
30    }
31}