Skip to content

Commit e8fc97f

Browse files
committed
make take generic when indices is a primitive vector
Signed-off-by: Connor Tsui <[email protected]>
1 parent de5f2b7 commit e8fc97f

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4+
use vortex_vector::match_each_unsigned_pvector;
5+
use vortex_vector::primitive::PVector;
6+
use vortex_vector::primitive::PrimitiveVector;
7+
8+
use crate::take::Take;
9+
10+
mod bool;
411
mod primitive;
512
mod pvector;
13+
14+
impl<T> Take<PrimitiveVector> for &T
15+
where
16+
for<'a> &'a T: Take<PVector<u8>, Output = T>,
17+
for<'a> &'a T: Take<PVector<u16>, Output = T>,
18+
for<'a> &'a T: Take<PVector<u32>, Output = T>,
19+
for<'a> &'a T: Take<PVector<u64>, Output = T>,
20+
{
21+
type Output = T;
22+
23+
fn take(self, indices: &PrimitiveVector) -> T {
24+
match_each_unsigned_pvector!(indices, |iv| { self.take(iv) })
25+
}
26+
}

vortex-compute/src/take/vector/primitive.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ use vortex_vector::primitive::PrimitiveVector;
99

1010
use crate::take::Take;
1111

12-
impl Take<PrimitiveVector> for &PrimitiveVector {
13-
type Output = PrimitiveVector;
14-
15-
fn take(self, indices: &PrimitiveVector) -> PrimitiveVector {
16-
match_each_pvector!(self, |v| { v.take(indices).into() })
17-
}
18-
}
19-
2012
impl<I: UnsignedPType> Take<PVector<I>> for &PrimitiveVector {
2113
type Output = PrimitiveVector;
2214

vortex-compute/src/take/vector/pvector.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@
44
use vortex_dtype::NativePType;
55
use vortex_dtype::UnsignedPType;
66
use vortex_vector::VectorOps;
7-
use vortex_vector::match_each_unsigned_pvector;
87
use vortex_vector::primitive::PVector;
9-
use vortex_vector::primitive::PrimitiveVector;
108

119
use crate::take::Take;
1210

13-
impl<T: NativePType> Take<PrimitiveVector> for &PVector<T> {
14-
type Output = PVector<T>;
15-
16-
fn take(self, indices: &PrimitiveVector) -> PVector<T> {
17-
match_each_unsigned_pvector!(indices, |iv| { self.take(iv) })
18-
}
19-
}
20-
2111
impl<T: NativePType, I: UnsignedPType> Take<PVector<I>> for &PVector<T> {
2212
type Output = PVector<T>;
2313

0 commit comments

Comments
 (0)