Skip to content

Commit fd4d04c

Browse files
committed
add Rhs generic parameter to Filter (#5328)
Signed-off-by: Connor Tsui <[email protected]>
1 parent f841c9c commit fd4d04c

File tree

8 files changed

+17
-25
lines changed

8 files changed

+17
-25
lines changed

vortex-compute/src/filter/bitbuffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::filter::Filter;
1010
// TODO(ngates): we need more experimentation to determine the best threshold here.
1111
const FILTER_SLICES_DENSITY_THRESHOLD: f64 = 0.8;
1212

13-
impl Filter for &BitBuffer {
13+
impl Filter<Mask> for &BitBuffer {
1414
type Output = BitBuffer;
1515

1616
fn filter(self, selection_mask: &Mask) -> BitBuffer {

vortex-compute/src/filter/buffer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::filter::Filter;
99
// This is modeled after the constant with the equivalent name in arrow-rs.
1010
const FILTER_SLICES_SELECTIVITY_THRESHOLD: f64 = 0.8;
1111

12-
impl<T: Copy> Filter for &Buffer<T> {
12+
impl<T: Copy> Filter<Mask> for &Buffer<T> {
1313
type Output = Buffer<T>;
1414

1515
fn filter(self, selection_mask: &Mask) -> Buffer<T> {
@@ -32,7 +32,7 @@ impl<T: Copy> Filter for &Buffer<T> {
3232
}
3333
}
3434

35-
impl<T: Copy> Filter for &mut BufferMut<T> {
35+
impl<T: Copy> Filter<Mask> for &mut BufferMut<T> {
3636
type Output = ();
3737

3838
fn filter(self, selection_mask: &Mask) {
@@ -69,7 +69,7 @@ impl<T: Copy> Filter for &mut BufferMut<T> {
6969
}
7070
}
7171

72-
impl<T: Copy> Filter for Buffer<T> {
72+
impl<T: Copy> Filter<Mask> for Buffer<T> {
7373
type Output = Self;
7474

7575
fn filter(self, selection_mask: &Mask) -> Self {

vortex-compute/src/filter/mask.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use vortex_mask::{Mask, MaskMut};
55

66
use crate::filter::Filter;
77

8-
impl Filter for &Mask {
8+
impl Filter<Mask> for &Mask {
99
type Output = Mask;
1010

1111
fn filter(self, selection_mask: &Mask) -> Mask {
@@ -28,7 +28,7 @@ impl Filter for &Mask {
2828
}
2929
}
3030

31-
impl Filter for &mut MaskMut {
31+
impl Filter<Mask> for &mut MaskMut {
3232
type Output = ();
3333

3434
fn filter(self, selection_mask: &Mask) {

vortex-compute/src/filter/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ mod buffer;
88
mod mask;
99
mod vector;
1010

11-
use vortex_mask::Mask;
12-
1311
/// Function for filtering based on a selection mask.
14-
pub trait Filter {
12+
pub trait Filter<Rhs> {
1513
/// The result type after performing the operation.
1614
type Output;
1715

@@ -22,5 +20,5 @@ pub trait Filter {
2220
/// # Panics
2321
///
2422
/// If the length of the mask does not equal the length of the value being filtered.
25-
fn filter(self, selection_mask: &Mask) -> Self::Output;
23+
fn filter(self, selection: &Rhs) -> Self::Output;
2624
}

vortex-compute/src/filter/vector/bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use vortex_vector::bool::BoolVector;
77

88
use crate::filter::Filter;
99

10-
impl Filter for &BoolVector {
10+
impl Filter<Mask> for &BoolVector {
1111
type Output = BoolVector;
1212

1313
fn filter(self, mask: &Mask) -> BoolVector {

vortex-compute/src/filter/vector/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod bool;
1010
mod primitive;
1111
mod pvector;
1212

13-
impl Filter for &mut VectorMut {
13+
impl Filter<Mask> for &mut VectorMut {
1414
type Output = ();
1515

1616
fn filter(self, selection_mask: &Mask) {

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,30 @@
33

44
use vortex_mask::Mask;
55
use vortex_vector::primitive::{PrimitiveVector, PrimitiveVectorMut};
6-
use vortex_vector::{VectorOps, match_each_pvector, match_each_pvector_mut};
6+
use vortex_vector::{match_each_pvector, match_each_pvector_mut};
77

88
use crate::filter::Filter;
99

10-
impl Filter for &PrimitiveVector {
10+
impl Filter<Mask> for &PrimitiveVector {
1111
type Output = PrimitiveVector;
1212

1313
fn filter(self, selection_mask: &Mask) -> PrimitiveVector {
1414
match_each_pvector!(self, |v| { v.filter(selection_mask).into() })
1515
}
1616
}
1717

18-
impl Filter for &mut PrimitiveVectorMut {
18+
impl Filter<Mask> for &mut PrimitiveVectorMut {
1919
type Output = ();
2020

2121
fn filter(self, selection_mask: &Mask) {
2222
match_each_pvector_mut!(self, |v| { v.filter(selection_mask) })
2323
}
2424
}
2525

26-
impl Filter for PrimitiveVector {
26+
impl Filter<Mask> for PrimitiveVector {
2727
type Output = Self;
2828

2929
fn filter(self, selection_mask: &Mask) -> Self {
30-
assert_eq!(
31-
selection_mask.len(),
32-
self.len(),
33-
"Selection mask length must equal the buffer length"
34-
);
35-
3630
match_each_pvector!(self, |v| { v.filter(selection_mask).into() })
3731
}
3832
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use vortex_vector::{VectorMutOps, VectorOps};
88

99
use crate::filter::Filter;
1010

11-
impl<T: NativePType> Filter for &PVector<T> {
11+
impl<T: NativePType> Filter<Mask> for &PVector<T> {
1212
type Output = PVector<T>;
1313

1414
fn filter(self, selection_mask: &Mask) -> PVector<T> {
@@ -27,7 +27,7 @@ impl<T: NativePType> Filter for &PVector<T> {
2727
}
2828
}
2929

30-
impl<T: NativePType> Filter for &mut PVectorMut<T> {
30+
impl<T: NativePType> Filter<Mask> for &mut PVectorMut<T> {
3131
type Output = ();
3232

3333
fn filter(self, selection_mask: &Mask) {
@@ -46,7 +46,7 @@ impl<T: NativePType> Filter for &mut PVectorMut<T> {
4646
}
4747
}
4848

49-
impl<T: NativePType> Filter for PVector<T> {
49+
impl<T: NativePType> Filter<Mask> for PVector<T> {
5050
type Output = Self;
5151

5252
fn filter(self, selection_mask: &Mask) -> Self {

0 commit comments

Comments
 (0)