Skip to content

Commit 3dc9a27

Browse files
authored
Use Validity::null_count in BitPacked::search_sorted (#2243)
1 parent 55a7e3a commit 3dc9a27

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

encodings/fastlanes/src/bitpacking/compute/search_sorted.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ use vortex_array::compute::{
88
IndexOrd, Len, SearchResult, SearchSorted, SearchSortedFn, SearchSortedSide,
99
SearchSortedUsizeFn,
1010
};
11-
use vortex_array::validity::Validity;
1211
use vortex_array::variants::PrimitiveArrayTrait;
1312
use vortex_dtype::{match_each_unsigned_integer_ptype, DType, NativePType};
14-
use vortex_error::{vortex_err, VortexError, VortexResult};
13+
use vortex_error::{VortexError, VortexResult};
1514
use vortex_scalar::Scalar;
1615

1716
use crate::{unpack_single_primitive, BitPackedArray, BitPackedEncoding};
@@ -158,17 +157,8 @@ impl<'a, T: BitPacking + NativePType> BitPackedSearch<'a, T> {
158157
.map(|p| p.min_index())
159158
.transpose()?
160159
.unwrap_or_else(|| array.len());
161-
let first_non_null_idx = match array.validity() {
162-
Validity::NonNullable | Validity::AllValid => 0,
163-
Validity::AllInvalid => array.len(),
164-
Validity::Array(varray) => {
165-
// In sorted order, nulls come before all the non-null values, i.e. we have true count worth of non null values at the end
166-
array.len()
167-
- varray.statistics().compute_true_count().ok_or_else(|| {
168-
vortex_err!("Couldn't compute true count for validity of bitpacked array")
169-
})?
170-
}
171-
};
160+
// In sorted order, nulls come before all the non-null values, i.e. we skip invalid_count worth of entries from beginning
161+
let first_non_null_idx = array.invalid_count()?;
172162

173163
Ok(Self {
174164
packed_as_slice: array.packed_slice::<T>(),

0 commit comments

Comments
 (0)