Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Jun 24, 2024
1 parent 5078610 commit e379b82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 3 additions & 4 deletions encodings/fastlanes/src/bitpacking/compute/search_sorted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ use crate::{unpack_single_primitive, BitPackedArray};

impl SearchSortedFn for BitPackedArray {
fn search_sorted(&self, value: &Scalar, side: SearchSortedSide) -> VortexResult<SearchResult> {
let ptype = self.ptype();
match_each_unsigned_integer_ptype!(ptype, |$P| {
match_each_unsigned_integer_ptype!(self.ptype(), |$P| {
let unwrapped_value: $P = value.cast(self.dtype())?.try_into().unwrap();
if let Some(patches_array) = self.patches() {
if (unwrapped_value.leading_zeros() as usize) < ptype.bit_width() - self.bit_width() {
if let Some(patches_array) = self.patches() {
if unwrapped_value as usize >= self.max_packed_value() {
search_sorted(&patches_array, value.clone(), side)
} else {
Ok(SearchSorted::search_sorted(&BitPackedSearch::new(self), &unwrapped_value, side))
Expand Down
5 changes: 5 additions & 0 deletions encodings/fastlanes/src/bitpacking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ impl BitPackedArray {
pub fn ptype(&self) -> PType {
self.dtype().try_into().unwrap()
}

#[inline]
pub fn max_packed_value(&self) -> usize {
1 << self.bit_width()
}
}

impl IntoCanonical for BitPackedArray {
Expand Down

0 comments on commit e379b82

Please sign in to comment.