Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Mar 5, 2024
1 parent 95f64b5 commit c43c2d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions vortex-array/src/array/primitive/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ impl<'a, T: NativePType> StatsCompute for NullableValues<'a, T> {

if first_non_null.is_none() {
return Ok(StatsSet::from(HashMap::from([
(Stat::Min, NullableScalar::None(T::PTYPE.into()).boxed()),
(Stat::Max, NullableScalar::None(T::PTYPE.into()).boxed()),
(Stat::Min, NullableScalar::none(T::PTYPE.into()).boxed()),
(Stat::Max, NullableScalar::none(T::PTYPE.into()).boxed()),
(Stat::IsConstant, true.into()),
(Stat::IsSorted, true.into()),
(Stat::IsStrictSorted, true.into()),
Expand Down Expand Up @@ -205,7 +205,7 @@ mod test {
bit_width_freq,
vec![
0u64, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0,
]
);
assert_eq!(run_count, 5);
Expand All @@ -228,4 +228,13 @@ mod test {
assert_eq!(min, Some(1));
assert_eq!(max, Some(2));
}

#[test]
fn all_null() {
let arr = PrimitiveArray::from_iter(vec![Option::<i32>::None, None, None]);
let min: Option<i32> = arr.stats().get_or_compute_as(&Stat::Min);
let max: Option<i32> = arr.stats().get_or_compute_as(&Stat::Max);
assert_eq!(min, None);
assert_eq!(max, None);
}
}
2 changes: 1 addition & 1 deletion vortex-fastlanes/src/for/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn for_compressor(array: &dyn Array, like: Option<&dyn Array>, ctx: CompressCtx)
let parray = array.as_primitive();

let child = match_each_integer_ptype!(parray.ptype(), |$T| {
let min = parray.stats().get_or_compute_as::<$T>(&Stat::Min).unwrap();
let min = parray.stats().get_or_compute_as::<$T>(&Stat::Min).unwrap_or(<$T>::default());
// TODO(ngates): check for overflow
let values = parray.buffer().typed_data::<$T>().iter().map(|v| v - min)
// TODO(ngates): cast to unsigned
Expand Down

0 comments on commit c43c2d9

Please sign in to comment.