diff --git a/encodings/fastlanes/src/bitpacking/compute/search_sorted.rs b/encodings/fastlanes/src/bitpacking/compute/search_sorted.rs index 896919b2b6..3f72cc273c 100644 --- a/encodings/fastlanes/src/bitpacking/compute/search_sorted.rs +++ b/encodings/fastlanes/src/bitpacking/compute/search_sorted.rs @@ -44,7 +44,7 @@ struct BitPackedSearch { impl BitPackedSearch { pub fn new(array: &BitPackedArray) -> Self { Self { - packed: array.packed().flatten_primitive().unwrap(), + packed: array.packed().into_primitive().unwrap(), length: array.len(), bit_width: array.bit_width(), min_patch_offset: array.patches().map(|p| { diff --git a/encodings/fastlanes/src/for/compress.rs b/encodings/fastlanes/src/for/compress.rs index e1ad2ecea8..8fc39df650 100644 --- a/encodings/fastlanes/src/for/compress.rs +++ b/encodings/fastlanes/src/for/compress.rs @@ -42,14 +42,6 @@ impl EncodingCompression for FoREncoding { return None; } - match_each_integer_ptype!(parray.ptype(), |$P| { - let min: $P = parray.statistics().compute_min()?; - let max: $P = parray.statistics().compute_max()?; - if max.wrapping_sub(min) < 0 { - return None; - } - }); - Some(self) } diff --git a/encodings/fastlanes/src/for/compute.rs b/encodings/fastlanes/src/for/compute.rs index b5f22ceec1..0e5f59f70e 100644 --- a/encodings/fastlanes/src/for/compute.rs +++ b/encodings/fastlanes/src/for/compute.rs @@ -78,10 +78,16 @@ impl SearchSortedFn for FoRArray { let shifted_min = min >> self.shift(); let unwrapped_value: $P = value.cast(self.dtype())?.try_into().unwrap(); let shifted_value: $P = unwrapped_value >> self.shift(); + // Make sure that smaller values are still smaller and not larger than (which they would be after wrapping_sub) if shifted_value < shifted_min { return Ok(SearchResult::NotFound(0)); } - let translated_scalar = Scalar::primitive(shifted_value.wrapping_sub(shifted_min), value.dtype().nullability()); + + let translated_scalar = Scalar::primitive( + shifted_value.wrapping_sub(shifted_min), + value.dtype().nullability(), + ) + .reinterpret_cast(self.ptype().to_unsigned()); search_sorted(&self.encoded(), translated_scalar, side) }) } diff --git a/vortex-array/src/array/sparse/mod.rs b/vortex-array/src/array/sparse/mod.rs index 1729c2e0b9..f09ba17a56 100644 --- a/vortex-array/src/array/sparse/mod.rs +++ b/vortex-array/src/array/sparse/mod.rs @@ -4,8 +4,8 @@ use vortex_error::vortex_bail; use vortex_scalar::Scalar; use crate::array::constant::ConstantArray; -use crate::compute::scalar_at::scalar_at; use crate::compute::search_sorted::{search_sorted, SearchSortedSide}; +use crate::compute::unary::scalar_at::scalar_at; use crate::stats::ArrayStatisticsCompute; use crate::validity::{ArrayValidity, LogicalValidity}; use crate::visitor::{AcceptArrayVisitor, ArrayVisitor};