@@ -5,15 +5,13 @@ use std::sync::{Arc, OnceLock};
55use arrow_array:: BooleanArray ;
66use arrow_buffer:: { BooleanBuffer , BooleanBufferBuilder } ;
77use 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
1210use crate :: array:: ConstantArray ;
1311use crate :: arrow:: FromArrowArray ;
1412use crate :: compute:: scalar_at;
1513use crate :: encoding:: Encoding ;
16- use crate :: stats:: ArrayStatistics ;
14+ use crate :: stats:: { ArrayStatistics , Stat } ;
1715use 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