Skip to content

Commit ec1fa8b

Browse files
authored
Do not force compute true count for FilterMask::try_from (#2024)
1 parent 026610f commit ec1fa8b

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

vortex-array/src/compute/filter.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ use std::sync::{Arc, OnceLock};
55
use arrow_array::BooleanArray;
66
use arrow_buffer::{BooleanBuffer, BooleanBufferBuilder};
77
use vortex_dtype::{DType, Nullability};
8-
use vortex_error::{
9-
vortex_bail, vortex_err, vortex_panic, VortexError, VortexExpect, VortexResult,
10-
};
8+
use vortex_error::{vortex_bail, vortex_panic, VortexError, VortexExpect, VortexResult};
119

1210
use crate::array::ConstantArray;
1311
use crate::arrow::FromArrowArray;
1412
use crate::compute::scalar_at;
1513
use crate::encoding::Encoding;
16-
use crate::stats::ArrayStatistics;
14+
use crate::stats::{ArrayStatistics, Stat};
1715
use crate::{ArrayDType, ArrayData, Canonical, IntoArrayData, IntoArrayVariant, IntoCanonical};
1816

1917
/// If the filter selects more than this fraction of rows, iterate over slices instead of indices.
@@ -567,16 +565,14 @@ impl TryFrom<ArrayData> for FilterMask {
567565
);
568566
}
569567

570-
let true_count = array
571-
.statistics()
572-
.compute_true_count()
573-
.ok_or_else(|| vortex_err!("Failed to compute true count for boolean array"))?;
574-
575-
if true_count == 0 {
576-
return Ok(Self::new_false(array.len()));
577-
}
578-
if true_count == array.len() {
579-
return Ok(Self::new_true(array.len()));
568+
if let Some(true_count) = array.statistics().get_as_cast::<u64>(Stat::TrueCount) {
569+
let len = array.len();
570+
if true_count == 0 {
571+
return Ok(Self::new_false(len));
572+
}
573+
if true_count == len as u64 {
574+
return Ok(Self::new_true(len));
575+
}
580576
}
581577

582578
// TODO(ngates): should we have a `to_filter_mask` compute function where encodings

0 commit comments

Comments
 (0)