Skip to content

Commit 1a903c4

Browse files
authored
expose row_block_size in WriteStrategy (#4741)
Signed-off-by: Onur Satici <[email protected]>
1 parent 05f1efe commit 1a903c4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

vortex-file/src/strategy.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use vortex_layout::layouts::struct_::writer::StructStrategy;
1616
use vortex_layout::layouts::zoned::writer::{ZonedLayoutOptions, ZonedStrategy};
1717

1818
const ONE_MEG: u64 = 1 << 20;
19-
const ROW_BLOCK_SIZE: usize = 8192;
2019

2120
/// Build a new [writer strategy][LayoutStrategy] to compress and reorganize chunks of a Vortex file.
2221
///
@@ -25,6 +24,7 @@ const ROW_BLOCK_SIZE: usize = 8192;
2524
/// bulk decoding performance, and IOPS required to perform an indexed read.
2625
pub struct WriteStrategyBuilder {
2726
compressor: Option<Arc<dyn CompressorPlugin>>,
27+
row_block_size: usize,
2828
}
2929

3030
impl Default for WriteStrategyBuilder {
@@ -37,7 +37,10 @@ impl WriteStrategyBuilder {
3737
/// Create a new empty builder. It can be further configured, and then finally built
3838
/// yielding the [`LayoutStrategy`].
3939
pub const fn new() -> Self {
40-
Self { compressor: None }
40+
Self {
41+
compressor: None,
42+
row_block_size: 8192,
43+
}
4144
}
4245

4346
/// Override the [compressor][CompressorPlugin] used for compressing chunks in the file.
@@ -49,6 +52,12 @@ impl WriteStrategyBuilder {
4952
self
5053
}
5154

55+
/// Override the row block size used to determine the zone map sizes.
56+
pub fn with_row_block_size(mut self, row_block_size: usize) -> Self {
57+
self.row_block_size = row_block_size;
58+
self
59+
}
60+
5261
/// Builds the canonical [`LayoutStrategy`] implementation, with the configured overrides
5362
/// applied.
5463
pub fn build(self) -> Arc<dyn LayoutStrategy> {
@@ -68,7 +77,7 @@ impl WriteStrategyBuilder {
6877
compressing,
6978
RepartitionWriterOptions {
7079
block_size_minimum: ONE_MEG,
71-
block_len_multiple: ROW_BLOCK_SIZE,
80+
block_len_multiple: self.row_block_size,
7281
canonicalize: true,
7382
},
7483
);
@@ -93,7 +102,7 @@ impl WriteStrategyBuilder {
93102
dict,
94103
compress_then_flat,
95104
ZonedLayoutOptions {
96-
block_size: ROW_BLOCK_SIZE,
105+
block_size: self.row_block_size,
97106
..Default::default()
98107
},
99108
);
@@ -105,7 +114,7 @@ impl WriteStrategyBuilder {
105114
// No minimum block size in bytes
106115
block_size_minimum: 0,
107116
// Always repartition into 8K row blocks
108-
block_len_multiple: ROW_BLOCK_SIZE,
117+
block_len_multiple: self.row_block_size,
109118
canonicalize: false,
110119
},
111120
);

0 commit comments

Comments
 (0)