@@ -43,6 +43,10 @@ pub struct ZoneMap {
4343 array : StructArray ,
4444 // The statistics that are included in the table.
4545 stats : Arc < [ Stat ] > ,
46+ // The length of each zone in the zone map.
47+ zone_len : usize ,
48+ // Number of rows that the zone map covers
49+ row_count : u64 ,
4650}
4751
4852impl ZoneMap {
@@ -52,24 +56,35 @@ impl ZoneMap {
5256 column_dtype : DType ,
5357 array : StructArray ,
5458 stats : Arc < [ Stat ] > ,
59+ zone_len : usize ,
60+ row_count : u64 ,
5561 ) -> VortexResult < Self > {
5662 let expected_dtype = stats_table_dtype ( & column_dtype, & stats) ;
5763 if & expected_dtype != array. dtype ( ) {
5864 vortex_bail ! ( "Array dtype does not match expected zone map dtype: {expected_dtype}" ) ;
5965 }
6066
6167 // SAFETY: We checked that the array matches the expected stats-table schema.
62- Ok ( unsafe { Self :: new_unchecked ( array, stats) } )
68+ Ok ( unsafe { Self :: new_unchecked ( array, stats, zone_len , row_count ) } )
6369 }
6470
6571 /// Creates [`ZoneMap`] without validating return array against expected stats.
6672 ///
6773 /// # Safety
6874 ///
6975 /// Assumes that the input struct array has the correct statistics as fields. Or in other words,
70- /// the [`DType`] of the input array is equal to the result of `stats_table_dtype`.
71- pub unsafe fn new_unchecked ( array : StructArray , stats : Arc < [ Stat ] > ) -> Self {
72- Self { array, stats }
76+ pub unsafe fn new_unchecked (
77+ array : StructArray ,
78+ stats : Arc < [ Stat ] > ,
79+ zone_len : usize ,
80+ row_count : u64 ,
81+ ) -> Self {
82+ Self {
83+ array,
84+ stats,
85+ zone_len,
86+ row_count,
87+ }
7388 }
7489
7590 /// Returns the [`DType`] of the statistics table given a set of statistics and column [`DType`].
@@ -144,8 +159,6 @@ impl ZoneMap {
144159 pub fn prune (
145160 & self ,
146161 predicate : & Expression ,
147- zone_len : u64 ,
148- row_count : u64 ,
149162 session : & VortexSession ,
150163 ) -> VortexResult < Mask > {
151164 let mut ctx = session. create_execution_ctx ( ) ;
@@ -157,7 +170,7 @@ impl ZoneMap {
157170 return applied. execute :: < Mask > ( & mut ctx) ;
158171 }
159172
160- let row_count_array = row_count_array ( zone_len, row_count, num_zones, & mut ctx) ?;
173+ let row_count_array = row_count_array ( self . zone_len , self . row_count , num_zones, & mut ctx) ?;
161174 let substituted = substitute_stats_fn_array :: < RowCount > ( applied, & row_count_array) ?;
162175 substituted. execute :: < Mask > ( & mut ctx)
163176 }
@@ -169,7 +182,7 @@ impl ZoneMap {
169182/// result is a [`ConstantArray`] for uniform zone sizes, otherwise a two-run
170183/// run-end encoded array whose trailing run carries the final zone length.
171184fn row_count_array (
172- zone_len : u64 ,
185+ zone_len : usize ,
173186 row_count : u64 ,
174187 num_zones : usize ,
175188 ctx : & mut ExecutionCtx ,
@@ -263,6 +276,7 @@ mod tests {
263276 ] )
264277 . unwrap ( ) ,
265278 Arc :: new ( [ Stat :: Max , Stat :: Min ] ) ,
279+ 10 ,
266280 )
267281 . unwrap ( ) ;
268282
0 commit comments