Skip to content

Commit 8a25fef

Browse files
authored
Temp fix: Make take bound by Copy instead of NativePType (#5666)
Just so we don't have to refactor the SIMD code to not rely on the `PTYPE` constant of `NativePType`. This will unblock being able to implement `take` for `DecimalVector` and then `batch_execute` for `DictArray`. --------- Signed-off-by: Connor Tsui <[email protected]>
1 parent e0833e2 commit 8a25fef

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

vortex-compute/src/take/buffer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use vortex_buffer::Buffer;
5-
use vortex_dtype::NativePType;
65
use vortex_dtype::UnsignedPType;
76

87
use crate::take::Take;
98

10-
impl<T: NativePType, I: UnsignedPType> Take<[I]> for &Buffer<T> {
9+
impl<T: Copy, I: UnsignedPType> Take<[I]> for &Buffer<T> {
1110
type Output = Buffer<T>;
1211

1312
fn take(self, indices: &[I]) -> Buffer<T> {

vortex-compute/src/take/slice/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! Take function implementations on slices.
55
66
use vortex_buffer::Buffer;
7-
use vortex_dtype::NativePType;
87
use vortex_dtype::UnsignedPType;
98

109
use crate::take::Take;
@@ -13,10 +12,13 @@ pub mod avx2;
1312
pub mod portable;
1413

1514
/// Specialized implementation for non-nullable indices.
16-
impl<T: NativePType, I: UnsignedPType> Take<[I]> for &[T] {
15+
impl<T: Copy, I: UnsignedPType> Take<[I]> for &[T] {
1716
type Output = Buffer<T>;
1817

1918
fn take(self, indices: &[I]) -> Buffer<T> {
19+
// TODO(connor): Make the SIMD implementations bound by `Copy` instead of `NativePType`.
20+
/*
21+
2022
#[cfg(vortex_nightly)]
2123
{
2224
return portable::take_portable(self, indices);
@@ -30,6 +32,8 @@ impl<T: NativePType, I: UnsignedPType> Take<[I]> for &[T] {
3032
}
3133
}
3234
35+
*/
36+
3337
#[allow(unreachable_code, reason = "`vortex_nightly` path returns early")]
3438
take_scalar(self, indices)
3539
}
@@ -40,6 +44,6 @@ impl<T: NativePType, I: UnsignedPType> Take<[I]> for &[T] {
4044
reason = "Compiler may see this as unused based on enabled features"
4145
)]
4246
#[inline]
43-
fn take_scalar<T: NativePType, I: UnsignedPType>(buffer: &[T], indices: &[I]) -> Buffer<T> {
47+
fn take_scalar<T: Copy, I: UnsignedPType>(buffer: &[T], indices: &[I]) -> Buffer<T> {
4448
indices.iter().map(|idx| buffer[idx.as_()]).collect()
4549
}

0 commit comments

Comments
 (0)