@@ -27,8 +27,8 @@ use vortex_layout::layouts::list::writer::ListLayoutStrategy;
2727use vortex_layout:: layouts:: repartition:: RepartitionStrategy ;
2828use vortex_layout:: layouts:: repartition:: RepartitionWriterOptions ;
2929use vortex_layout:: layouts:: table:: TableStrategy ;
30- use vortex_layout:: layouts:: zoned:: writer:: ZonedLayoutOptions ;
31- use vortex_layout:: layouts:: zoned:: writer:: ZonedStrategy ;
30+ use vortex_layout:: layouts:: zoned:: writer:: ZoneOptions ;
31+ use vortex_layout:: layouts:: zoned:: writer:: ZonedStrategyBuilder ;
3232use vortex_session:: VortexSession ;
3333use vortex_utils:: aliases:: hash_map:: HashMap ;
3434
@@ -66,6 +66,7 @@ pub struct WriteStrategyBuilder {
6666 ///
6767 /// [`ListLayoutStrategy`]: vortex_layout::layouts::list::writer::ListLayoutStrategy
6868 use_list_layout : bool ,
69+ zoned : Option < ZonedStrategyBuilder > ,
6970}
7071
7172impl WriteStrategyBuilder {
@@ -84,10 +85,12 @@ impl WriteStrategyBuilder {
8485 use_list_layout : session
8586 . enabled_component_ids ( ComponentKind :: Layout )
8687 . contains ( & List . id ( ) ) ,
88+ zoned : None ,
8789 }
8890 }
8991
90- /// Override the row block size used for row repartitioning and zoned statistics.
92+ /// Override the row block size used for row repartitioning and, unless [`Self::with_zoned`]
93+ /// is set, the zone length of zoned statistics.
9194 ///
9295 /// Larger blocks reduce footer/statistics overhead. Smaller blocks can improve pruning and
9396 /// random-access locality.
@@ -96,6 +99,16 @@ impl WriteStrategyBuilder {
9699 self
97100 }
98101
102+ /// Override the zone maps written for each column.
103+ ///
104+ /// By default every column gets one zone map of [`Self::with_row_block_size`] rows holding the
105+ /// default pruning aggregates. Field paths are matched after the root struct is split into
106+ /// columns, as for [`Self::with_field_writer`].
107+ pub fn with_zoned ( mut self , zoned : ZonedStrategyBuilder ) -> Self {
108+ self . zoned = Some ( zoned) ;
109+ self
110+ }
111+
99112 /// Override the target uncompressed byte size used to coalesce data blocks.
100113 ///
101114 /// Passing `None` disables byte-size coalescing, so blocks retain the row granularity set by
@@ -221,16 +234,12 @@ impl WriteStrategyBuilder {
221234 ) ;
222235
223236 let row_block_size = NonZeroUsize :: new ( self . row_block_size ) . vortex_expect ( "must be non 0" ) ;
237+ let zoned = self . zoned . unwrap_or_else ( || {
238+ ZonedStrategyBuilder :: new ( ) . with_zones ( [ ZoneOptions :: new ( row_block_size) ] )
239+ } ) ;
224240
225241 // 2. calculate stats for each row group
226- let stats = ZonedStrategy :: new (
227- dict,
228- compress_then_flat. clone ( ) ,
229- ZonedLayoutOptions {
230- block_size : row_block_size,
231- ..Default :: default ( )
232- } ,
233- ) ;
242+ let stats = zoned. clone ( ) . build ( dict, compress_then_flat. clone ( ) ) ;
234243
235244 // 1. repartition each column to fixed row counts
236245 let repartition = RepartitionStrategy :: new (
@@ -257,14 +266,7 @@ impl WriteStrategyBuilder {
257266 // We need a closure here to enable recursive application of list layout.
258267 table_strategy = table_strategy. with_list_layout_factory (
259268 move |list_layout : ListLayoutStrategy | -> Arc < dyn LayoutStrategy > {
260- let zoned = ZonedStrategy :: new (
261- list_layout,
262- compress_then_flat. clone ( ) ,
263- ZonedLayoutOptions {
264- block_size : row_block_size,
265- ..Default :: default ( )
266- } ,
267- ) ;
269+ let zoned = zoned. clone ( ) . build ( list_layout, compress_then_flat. clone ( ) ) ;
268270 Arc :: new ( RepartitionStrategy :: new (
269271 zoned,
270272 RepartitionWriterOptions {
0 commit comments