@@ -17,6 +17,7 @@ use vortex_array::aggregate_fn::AggregateFnVTable;
1717use vortex_array:: dtype:: DType ;
1818use vortex_array:: dtype:: Nullability ;
1919use vortex_array:: scalar:: Scalar ;
20+ use vortex_error:: VortexExpect ;
2021use vortex_error:: VortexResult ;
2122use vortex_error:: vortex_ensure_eq;
2223use vortex_error:: vortex_err;
@@ -29,6 +30,7 @@ mod partial;
2930pub ( in crate :: layouts:: zoned) mod constant;
3031pub use partial:: BloomPartial ;
3132
33+ use crate :: layouts:: zoned:: aggregates:: bloom_filter:: partial:: BLOCK_SIZE ;
3234use crate :: layouts:: zoned:: skip_index:: bloom:: is_bloom_valid_dtype;
3335
3436// 1. (joacoc) Opted for blocks_count as a simpler way to tune
@@ -82,7 +84,8 @@ const DEFAULT_BLOCKS_COUNT: usize = 256;
8284impl Default for BloomOptions {
8385 fn default ( ) -> Self {
8486 Self {
85- blocks_count : NonZeroUsize :: new ( DEFAULT_BLOCKS_COUNT ) . expect ( "valid blocks size" ) ,
87+ blocks_count : NonZeroUsize :: new ( DEFAULT_BLOCKS_COUNT )
88+ . vortex_expect ( "valid blocks size" ) ,
8689 }
8790 }
8891}
@@ -184,7 +187,7 @@ impl AggregateFnVTable for BloomFilter {
184187 ///
185188 /// Basically turns each block into a single byte sequence.
186189 fn to_scalar ( & self , partial : & Self :: Partial ) -> VortexResult < Scalar > {
187- let mut bytes = Vec :: with_capacity ( partial. blocks . len ( ) * 8 * size_of :: < u32 > ( ) ) ;
190+ let mut bytes = Vec :: with_capacity ( partial. blocks . len ( ) * BLOCK_SIZE ) ;
188191 bytes. extend (
189192 partial
190193 . blocks
@@ -239,6 +242,7 @@ pub(in crate::layouts::zoned::aggregates::bloom_filter) mod test_utils {
239242 use vortex_error:: vortex_ensure;
240243
241244 use super :: * ;
245+ use crate :: layouts:: zoned:: aggregates:: bloom_filter:: partial:: BLOCK_SIZE ;
242246
243247 pub fn setup ( ) -> VortexResult < ExecutionCtx > {
244248 let session = vortex_array:: array_session ( ) ;
@@ -255,10 +259,7 @@ pub(in crate::layouts::zoned::aggregates::bloom_filter) mod test_utils {
255259
256260 pub fn extract_bloom_blocks ( state : & Scalar ) -> VortexResult < Vec < [ u32 ; 8 ] > > {
257261 let bytes = state. as_binary ( ) . value ( ) . expect ( "bloom state is non-null" ) ;
258- vortex_ensure ! (
259- bytes. len( ) % ( 8 * size_of:: <u32 >( ) ) == 0 ,
260- "invalid bloom state length"
261- ) ;
262+ vortex_ensure ! ( bytes. len( ) % BLOCK_SIZE == 0 , "invalid bloom state length" ) ;
262263 let mut blocks = Vec :: with_capacity ( bytes. len ( ) / 32 ) ;
263264 for block_bytes in bytes. chunks_exact ( 32 ) {
264265 let mut block = [ 0u32 ; 8 ] ;
0 commit comments