Skip to content

Commit

Permalink
Short-circuit BoolArray null count (#1509)
Browse files Browse the repository at this point in the history
I believe this is the regression from
10a1f21

It checks both true_count and null_count, but the null count was
triggering a full stats compute.
  • Loading branch information
gatesn authored Nov 28, 2024
1 parent 787106c commit 61e838e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions vortex-array/src/array/bool/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ impl StatisticsVTable<NullableBools<'_>> for BoolEncoding {
// Fast-path if we just want the true-count
if matches!(
stat,
Stat::TrueCount | Stat::Min | Stat::Max | Stat::IsConstant
Stat::TrueCount | Stat::Min | Stat::Max | Stat::IsConstant | Stat::NullCount
) {
let _null_count = array.1.count_set_bits();
return Ok(StatsSet::bools_with_true_and_null_count(
array.0.bitand(array.1).count_set_bits(),
array.1.count_set_bits(),
array.1.len() - array.1.count_set_bits(),
array.0.len(),
));
}
Expand Down Expand Up @@ -85,7 +86,7 @@ impl StatisticsVTable<BooleanBuffer> for BoolEncoding {
// Fast-path if we just want the true-count
if matches!(
stat,
Stat::TrueCount | Stat::Min | Stat::Max | Stat::IsConstant
Stat::TrueCount | Stat::Min | Stat::Max | Stat::IsConstant | Stat::NullCount
) {
return Ok(StatsSet::bools_with_true_and_null_count(
buffer.count_set_bits(),
Expand Down
3 changes: 2 additions & 1 deletion vortex-array/src/stats/statsset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ impl StatsSet {
true_count: usize,
null_count: usize,
len: usize,
) -> StatsSet {
) -> Self {
StatsSet::from_iter([
(Stat::TrueCount, true_count.into()),
(Stat::NullCount, null_count.into()),
(Stat::Min, (true_count == len).into()),
(Stat::Max, (true_count > 0).into()),
(
Expand Down

0 comments on commit 61e838e

Please sign in to comment.