Skip to content

Commit 5efe3a9

Browse files
committed
more
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 85f7fd0 commit 5efe3a9

4 files changed

Lines changed: 779 additions & 5 deletions

File tree

vortex-array/src/arrays/filter/execute/buffer.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use vortex_buffer::Buffer;
1212
use vortex_mask::MaskValues;
1313

1414
use crate::arrays::filter::execute::byte_compress;
15+
use crate::arrays::filter::execute::simd_compress;
1516
use crate::arrays::filter::execute::slice;
1617

1718
const CACHED_INDICES_MAX_DENSITY: f64 = 0.5;
@@ -21,8 +22,8 @@ const MIN_SLICES_AVERAGE_RUN_LENGTH: usize = 8;
2122
/// Filter a [`Buffer<T>`] by [`MaskValues`], returning a new buffer.
2223
///
2324
/// Dense uniquely owned buffers are compacted in place. Shared and sparse buffers allocate an
24-
/// exact-sized output and choose between cached indices, cached long ranges, bitmap iteration,
25-
/// and byte-compress based on the mask and element width.
25+
/// exact-sized output and choose between cached indices, cached long ranges, SIMD compress,
26+
/// bitmap iteration, and byte-compress based on the mask, element width, and CPU features.
2627
pub(super) fn filter_buffer<T: Copy>(buffer: Buffer<T>, mask: &MaskValues) -> Buffer<T> {
2728
assert_eq!(buffer.len(), mask.len());
2829

@@ -53,6 +54,10 @@ fn filter_slice<T: Copy>(values: &[T], mask: &MaskValues) -> Buffer<T> {
5354
return slice::filter_slice_by_indices(values, indices);
5455
}
5556

57+
if let Some(filtered) = simd_compress::filter_slice_by_bitmap(values, mask) {
58+
return filtered;
59+
}
60+
5661
if mask.density() >= byte_compress_density_threshold::<T>() {
5762
byte_compress::filter_buffer(values, mask)
5863
} else {
@@ -71,6 +76,10 @@ fn filter_slice_in_place<T: Copy>(values: &mut [T], mask: &MaskValues) -> usize
7176
return slice::filter_slice_mut_by_indices(values, indices);
7277
}
7378

79+
if let Some(new_len) = simd_compress::filter_slice_mut_by_bitmap(values, mask) {
80+
return new_len;
81+
}
82+
7483
slice::filter_slice_mut_by_bitmap(values, mask)
7584
}
7685

vortex-array/src/arrays/filter/execute/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ mod decimal;
3737
mod fixed_size_list;
3838
mod listview;
3939
mod primitive;
40+
mod simd_compress;
4041
mod slice;
4142
mod struct_;
4243
pub mod take;

0 commit comments

Comments
 (0)