Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ vortex-fsst = { version = "0.22.1", path = "./encodings/fsst" }
vortex-io = { version = "0.22.1", path = "./vortex-io" }
vortex-ipc = { version = "0.22.1", path = "./vortex-ipc" }
vortex-layout = { version = "0.22.1", path = "./vortex-layout" }
vortex-mask = { version = "0.22.1", path = "./vortex-mask" }
vortex-proto = { version = "0.22.1", path = "./vortex-proto" }
vortex-runend = { version = "0.22.1", path = "./encodings/runend" }
vortex-scalar = { version = "0.22.1", path = "./vortex-scalar", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions encodings/alp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ vortex-buffer = { workspace = true }
vortex-dtype = { workspace = true }
vortex-error = { workspace = true }
vortex-fastlanes = { workspace = true }
vortex-mask = { workspace = true }
vortex-scalar = { workspace = true }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions encodings/alp/src/alp/compute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use vortex_array::compute::{
filter, scalar_at, slice, take, ComputeVTable, FilterFn, FilterMask, ScalarAtFn, SliceFn,
TakeFn,
filter, scalar_at, slice, take, ComputeVTable, FilterFn, ScalarAtFn, SliceFn, TakeFn,
};
use vortex_array::variants::PrimitiveArrayTrait;
use vortex_array::{ArrayDType, ArrayData, IntoArrayData};
use vortex_error::VortexResult;
use vortex_mask::Mask;
use vortex_scalar::Scalar;

use crate::{match_each_alp_float_ptype, ALPArray, ALPEncoding, ALPFloat};
Expand Down Expand Up @@ -79,7 +79,7 @@ impl SliceFn<ALPArray> for ALPEncoding {
}

impl FilterFn<ALPArray> for ALPEncoding {
fn filter(&self, array: &ALPArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &ALPArray, mask: &Mask) -> VortexResult<ArrayData> {
let patches = array
.patches()
.map(|p| p.filter(mask))
Expand Down
19 changes: 9 additions & 10 deletions encodings/alp/src/alp_rd/compute/filter.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use vortex_array::compute::{filter, FilterFn, FilterMask};
use vortex_array::compute::{filter, FilterFn};
use vortex_array::{ArrayDType, ArrayData, IntoArrayData};
use vortex_error::VortexResult;
use vortex_mask::Mask;

use crate::{ALPRDArray, ALPRDEncoding};

impl FilterFn<ALPRDArray> for ALPRDEncoding {
fn filter(&self, array: &ALPRDArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &ALPRDArray, mask: &Mask) -> VortexResult<ArrayData> {
let left_parts_exceptions = array
.left_parts_patches()
.map(|patches| patches.filter(mask))
Expand All @@ -28,10 +29,11 @@ impl FilterFn<ALPRDArray> for ALPRDEncoding {
mod test {
use rstest::rstest;
use vortex_array::array::PrimitiveArray;
use vortex_array::compute::{filter, FilterMask};
use vortex_array::compute::filter;
use vortex_array::validity::Validity;
use vortex_array::IntoArrayVariant;
use vortex_buffer::buffer;
use vortex_mask::Mask;

use crate::{ALPRDFloat, RDEncoder};

Expand All @@ -46,13 +48,10 @@ mod test {
assert!(encoded.left_parts_patches().is_some());

// The first two values need no patching
let filtered = filter(
encoded.as_ref(),
&FilterMask::from_iter([true, false, true]),
)
.unwrap()
.into_primitive()
.unwrap();
let filtered = filter(encoded.as_ref(), &Mask::from_iter([true, false, true]))
.unwrap()
.into_primitive()
.unwrap();
assert_eq!(filtered.as_slice::<T>(), &[a, outlier]);
}
}
1 change: 1 addition & 0 deletions encodings/datetime-parts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ vortex-buffer = { workspace = true }
vortex-datetime-dtype = { workspace = true }
vortex-dtype = { workspace = true }
vortex-error = { workspace = true }
vortex-mask = { workspace = true }
vortex-scalar = { workspace = true }

[dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions encodings/datetime-parts/src/compute/filter.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use vortex_array::compute::{filter, FilterFn, FilterMask};
use vortex_array::compute::{filter, FilterFn};
use vortex_array::{ArrayDType, ArrayData, IntoArrayData};
use vortex_error::VortexResult;
use vortex_mask::Mask;

use crate::{DateTimePartsArray, DateTimePartsEncoding};

impl FilterFn<DateTimePartsArray> for DateTimePartsEncoding {
fn filter(&self, array: &DateTimePartsArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &DateTimePartsArray, mask: &Mask) -> VortexResult<ArrayData> {
Ok(DateTimePartsArray::try_new(
array.dtype().clone(),
filter(array.days().as_ref(), mask)?,
Expand Down
1 change: 1 addition & 0 deletions encodings/dict/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ vortex-array = { workspace = true }
vortex-buffer = { workspace = true }
vortex-dtype = { workspace = true }
vortex-error = { workspace = true }
vortex-mask = { workspace = true }
vortex-scalar = { workspace = true }

[lints]
Expand Down
7 changes: 4 additions & 3 deletions encodings/dict/src/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ mod compare;
mod like;

use vortex_array::compute::{
filter, scalar_at, slice, take, BinaryNumericFn, CompareFn, ComputeVTable, FilterFn,
FilterMask, LikeFn, ScalarAtFn, SliceFn, TakeFn,
filter, scalar_at, slice, take, BinaryNumericFn, CompareFn, ComputeVTable, FilterFn, LikeFn,
ScalarAtFn, SliceFn, TakeFn,
};
use vortex_array::{ArrayData, IntoArrayData};
use vortex_error::VortexResult;
use vortex_mask::Mask;
use vortex_scalar::Scalar;

use crate::{DictArray, DictEncoding};
Expand Down Expand Up @@ -60,7 +61,7 @@ impl TakeFn<DictArray> for DictEncoding {
}

impl FilterFn<DictArray> for DictEncoding {
fn filter(&self, array: &DictArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &DictArray, mask: &Mask) -> VortexResult<ArrayData> {
let codes = filter(&array.codes(), mask)?;
DictArray::try_new(codes, array.values()).map(|a| a.into_array())
}
Expand Down
1 change: 1 addition & 0 deletions encodings/fastlanes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ vortex-array = { workspace = true }
vortex-buffer = { workspace = true }
vortex-dtype = { workspace = true }
vortex-error = { workspace = true }
vortex-mask = { workspace = true }
vortex-scalar = { workspace = true }

[dev-dependencies]
Expand Down
24 changes: 12 additions & 12 deletions encodings/fastlanes/src/bitpacking/compute/filter.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use arrow_buffer::ArrowNativeType;
use fastlanes::BitPacking;
use vortex_array::array::PrimitiveArray;
use vortex_array::compute::{filter, FilterFn, FilterIter, FilterMask};
use vortex_array::compute::{filter, FilterFn};
use vortex_array::variants::PrimitiveArrayTrait;
use vortex_array::{ArrayData, IntoArrayData, IntoArrayVariant};
use vortex_buffer::{Buffer, BufferMut};
use vortex_dtype::{match_each_unsigned_integer_ptype, NativePType};
use vortex_error::VortexResult;
use vortex_mask::{Mask, MaskIter};

use super::chunked_indices;
use crate::bitpacking::compute::take::UNPACK_CHUNK_THRESHOLD;
use crate::{BitPackedArray, BitPackedEncoding};

impl FilterFn<BitPackedArray> for BitPackedEncoding {
fn filter(&self, array: &BitPackedArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &BitPackedArray, mask: &Mask) -> VortexResult<ArrayData> {
let primitive = match_each_unsigned_integer_ptype!(array.ptype().to_unsigned(), |$I| {
filter_primitive::<$I>(array, mask)
});
Expand All @@ -31,7 +32,7 @@ impl FilterFn<BitPackedArray> for BitPackedEncoding {
/// dictates the final `PType` of the result.
fn filter_primitive<T: NativePType + BitPacking + ArrowNativeType>(
array: &BitPackedArray,
mask: &FilterMask,
mask: &Mask,
) -> VortexResult<PrimitiveArray> {
let validity = array.validity().filter(mask)?;

Expand All @@ -48,12 +49,10 @@ fn filter_primitive<T: NativePType + BitPacking + ArrowNativeType>(
}

let values: Buffer<T> = match mask.iter() {
FilterIter::Indices(indices) => {
MaskIter::Indices(indices) => {
filter_indices(array, mask.true_count(), indices.iter().copied())
}
FilterIter::Slices(slices) => {
filter_slices(array, mask.true_count(), slices.iter().copied())
}
MaskIter::Slices(slices) => filter_slices(array, mask.true_count(), slices.iter().copied()),
};

let mut values = PrimitiveArray::new(values, validity).reinterpret_cast(array.ptype());
Expand Down Expand Up @@ -128,10 +127,11 @@ fn filter_slices<T: NativePType + BitPacking + ArrowNativeType>(
#[cfg(test)]
mod test {
use vortex_array::array::PrimitiveArray;
use vortex_array::compute::{filter, slice, FilterMask};
use vortex_array::compute::{filter, slice};
use vortex_array::validity::Validity;
use vortex_array::{ArrayLen, IntoArrayVariant};
use vortex_buffer::Buffer;
use vortex_mask::Mask;

use crate::BitPackedArray;

Expand All @@ -141,7 +141,7 @@ mod test {
let unpacked = PrimitiveArray::from_iter((0..4096).map(|i| (i % 63) as u8));
let bitpacked = BitPackedArray::encode(unpacked.as_ref(), 6).unwrap();

let mask = FilterMask::from_indices(bitpacked.len(), vec![0, 125, 2047, 2049, 2151, 2790]);
let mask = Mask::from_indices(bitpacked.len(), vec![0, 125, 2047, 2049, 2151, 2790]);

let primitive_result = filter(bitpacked.as_ref(), &mask)
.unwrap()
Expand All @@ -158,7 +158,7 @@ mod test {
let bitpacked = BitPackedArray::encode(unpacked.as_ref(), 6).unwrap();
let sliced = slice(bitpacked.as_ref(), 128, 2050).unwrap();

let mask = FilterMask::from_indices(sliced.len(), vec![1919, 1921]);
let mask = Mask::from_indices(sliced.len(), vec![1919, 1921]);

let primitive_result = filter(&sliced, &mask).unwrap().into_primitive().unwrap();
let res_bytes = primitive_result.as_slice::<u8>();
Expand All @@ -171,7 +171,7 @@ mod test {
let bitpacked = BitPackedArray::encode(unpacked.as_ref(), 6).unwrap();
let filtered = filter(
bitpacked.as_ref(),
&FilterMask::from_indices(4096, (0..1024).collect()),
&Mask::from_indices(4096, (0..1024).collect()),
)
.unwrap();
assert_eq!(
Expand All @@ -187,7 +187,7 @@ mod test {
let bitpacked = BitPackedArray::encode(unpacked.as_ref(), 9).unwrap();
let filtered = filter(
bitpacked.as_ref(),
&FilterMask::from_indices(values.len(), (0..250).collect()),
&Mask::from_indices(values.len(), (0..250).collect()),
)
.unwrap()
.into_primitive()
Expand Down
7 changes: 4 additions & 3 deletions encodings/fastlanes/src/for/compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use std::ops::AddAssign;

use num_traits::{CheckedShl, CheckedShr, WrappingAdd, WrappingSub};
use vortex_array::compute::{
filter, scalar_at, search_sorted, slice, take, CompareFn, ComputeVTable, FilterFn, FilterMask,
ScalarAtFn, SearchResult, SearchSortedFn, SearchSortedSide, SliceFn, TakeFn,
filter, scalar_at, search_sorted, slice, take, CompareFn, ComputeVTable, FilterFn, ScalarAtFn,
SearchResult, SearchSortedFn, SearchSortedSide, SliceFn, TakeFn,
};
use vortex_array::variants::PrimitiveArrayTrait;
use vortex_array::{ArrayDType, ArrayData, IntoArrayData};
use vortex_dtype::{match_each_integer_ptype, NativePType};
use vortex_error::{VortexError, VortexExpect as _, VortexResult};
use vortex_mask::Mask;
use vortex_scalar::{PValue, Scalar};

use crate::{FoRArray, FoREncoding};
Expand Down Expand Up @@ -53,7 +54,7 @@ impl TakeFn<FoRArray> for FoREncoding {
}

impl FilterFn<FoRArray> for FoREncoding {
fn filter(&self, array: &FoRArray, mask: &FilterMask) -> VortexResult<ArrayData> {
fn filter(&self, array: &FoRArray, mask: &Mask) -> VortexResult<ArrayData> {
FoRArray::try_new(
filter(&array.encoded(), mask)?,
array.reference_scalar(),
Expand Down
1 change: 1 addition & 0 deletions encodings/fsst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ vortex-array = { workspace = true }
vortex-buffer = { workspace = true }
vortex-dtype = { workspace = true }
vortex-error = { workspace = true }
vortex-mask = { workspace = true }
vortex-scalar = { workspace = true }

[dev-dependencies]
Expand Down
Loading
Loading