44//! Bool compression statistics.
55
66use vortex_array:: arrays:: BoolArray ;
7- use vortex_error:: VortexExpect ;
87use vortex_error:: VortexResult ;
98use vortex_mask:: AllOr ;
109
11- use super :: GenerateStatsOptions ;
12-
1310/// Array of booleans and relevant stats for compression.
1411#[ derive( Clone , Debug ) ]
1512pub struct BoolStats {
@@ -24,24 +21,12 @@ pub struct BoolStats {
2421}
2522
2623impl BoolStats {
27- /// Generates stats with default options.
28- pub fn generate ( input : & BoolArray ) -> Self {
29- Self :: generate_opts ( input, GenerateStatsOptions :: default ( ) )
30- }
31-
32- /// Generates stats with provided options.
33- ///
34- /// For booleans, all stats are cheap to compute so the options are currently ignored.
35- pub fn generate_opts ( input : & BoolArray , opts : GenerateStatsOptions ) -> Self {
36- Self :: generate_opts_fallible ( input, opts)
37- . vortex_expect ( "BoolStats::generate_opts should not fail" )
38- }
39-
4024 /// Generates stats, returning an error on failure.
41- fn generate_opts_fallible (
42- input : & BoolArray ,
43- _opts : GenerateStatsOptions ,
44- ) -> VortexResult < Self > {
25+ ///
26+ /// # Errors
27+ ///
28+ /// Returns an error if getting validity mask fails or values exceed `u32` bounds.
29+ pub fn generate ( input : & BoolArray ) -> VortexResult < Self > {
4530 if input. is_empty ( ) {
4631 return Ok ( Self {
4732 src : input. clone ( ) ,
@@ -125,7 +110,7 @@ mod tests {
125110 BitBuffer :: from ( vec ! [ true , true , true ] ) ,
126111 Validity :: NonNullable ,
127112 ) ;
128- let stats = BoolStats :: generate ( & array) ;
113+ let stats = BoolStats :: generate ( & array) ? ;
129114 assert_eq ! ( stats. value_count, 3 ) ;
130115 assert_eq ! ( stats. null_count, 0 ) ;
131116 assert_eq ! ( stats. true_count, 3 ) ;
@@ -139,7 +124,7 @@ mod tests {
139124 BitBuffer :: from ( vec ! [ false , false , false ] ) ,
140125 Validity :: NonNullable ,
141126 ) ;
142- let stats = BoolStats :: generate ( & array) ;
127+ let stats = BoolStats :: generate ( & array) ? ;
143128 assert_eq ! ( stats. value_count, 3 ) ;
144129 assert_eq ! ( stats. null_count, 0 ) ;
145130 assert_eq ! ( stats. true_count, 0 ) ;
@@ -153,7 +138,7 @@ mod tests {
153138 BitBuffer :: from ( vec ! [ true , false , true ] ) ,
154139 Validity :: NonNullable ,
155140 ) ;
156- let stats = BoolStats :: generate ( & array) ;
141+ let stats = BoolStats :: generate ( & array) ? ;
157142 assert_eq ! ( stats. value_count, 3 ) ;
158143 assert_eq ! ( stats. null_count, 0 ) ;
159144 assert_eq ! ( stats. true_count, 2 ) ;
@@ -167,7 +152,7 @@ mod tests {
167152 BitBuffer :: from ( vec ! [ true , false , true ] ) ,
168153 Validity :: from_iter ( [ true , false , true ] ) ,
169154 ) ;
170- let stats = BoolStats :: generate ( & array) ;
155+ let stats = BoolStats :: generate ( & array) ? ;
171156 assert_eq ! ( stats. value_count, 2 ) ;
172157 assert_eq ! ( stats. null_count, 1 ) ;
173158 assert_eq ! ( stats. true_count, 2 ) ;
0 commit comments