Skip to content

Commit e35aeec

Browse files
committed
docs: Update comments
Signed-off-by: peasee <[email protected]>
1 parent daabd21 commit e35aeec

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

vortex-datafusion/src/persistent/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl VortexFormatFactory {
122122
/// use vortex_datafusion::VortexFormatFactory;
123123
/// use vortex::file::VortexWriteOptionsFactory;
124124
///
125-
/// let factory = VortexFormatFactory::new().with_write_options(VortexWriteOptionsFactory::default());
125+
/// let factory = VortexFormatFactory::new().with_write_options_factory(VortexWriteOptionsFactory::default());
126126
/// ```
127127
pub fn with_write_options_factory(
128128
mut self,
@@ -206,9 +206,9 @@ impl VortexFormat {
206206
//// For example:
207207
/// ```rust
208208
/// use vortex_datafusion::VortexFormat;
209-
/// use vortex::file::VortexWriteOptions;
209+
/// use vortex::file::VortexWriteOptionsFactory;
210210
///
211-
/// let format = VortexFormat::default().with_write_options(VortexWriteOptions::default());
211+
/// let format = VortexFormat::default().with_write_options_factory(VortexWriteOptionsFactory::default());
212212
/// ```
213213
pub fn with_write_options_factory(
214214
mut self,
@@ -223,7 +223,7 @@ impl VortexFormat {
223223
&self.opts
224224
}
225225

226-
/// Return the write options
226+
/// Return the write options factory
227227
pub fn write_options_factory(&self) -> Arc<VortexWriteOptionsFactory> {
228228
Arc::clone(&self.write_options_factory)
229229
}

vortex-file/src/writer.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ const DEFAULT_EXCLUDE_DTYPE: bool = false;
3333
const DEFAULT_MAX_VARIABLE_LENGTH_STATISTICS_SIZE: usize = 64;
3434
const DEFAULT_FILE_STATISTICS: &[Stat] = PRUNING_STATS;
3535

36+
/// Factory for creating [`VortexWriteOptions`] with custom defaults.
37+
///
38+
/// This can be used to configure writer options before acquiring a handle, where we later reuse the options but need to source an available handle.
39+
///
40+
/// This factory maintains the default behaviour of [`VortexWriteOptions::default`].
3641
#[derive(Clone)]
3742
pub struct VortexWriteOptionsFactory {
38-
strategy: Arc<dyn LayoutStrategy>,
43+
strategy: Option<Arc<dyn LayoutStrategy>>,
3944
exclude_dtype: Option<bool>,
4045
max_variable_length_statistics_size: Option<usize>,
4146
file_statistics: Option<Vec<Stat>>,
@@ -57,7 +62,7 @@ impl std::fmt::Debug for VortexWriteOptionsFactory {
5762
impl Default for VortexWriteOptionsFactory {
5863
fn default() -> Self {
5964
Self {
60-
strategy: WriteStrategyBuilder::new().build(),
65+
strategy: None,
6166
exclude_dtype: None,
6267
max_variable_length_statistics_size: None,
6368
file_statistics: None,
@@ -66,15 +71,20 @@ impl Default for VortexWriteOptionsFactory {
6671
}
6772

6873
impl VortexWriteOptionsFactory {
74+
/// Create a new builder with default settings.
6975
pub fn new() -> Self {
7076
Self::default()
7177
}
7278

79+
/// Replace the default layout strategy with the provided one.
7380
pub fn with_strategy(mut self, strategy: Arc<dyn LayoutStrategy>) -> Self {
74-
self.strategy = strategy;
81+
self.strategy = Some(strategy);
7582
self
7683
}
7784

85+
/// Exclude the DType from the Vortex file. You must provide the DType to the reader.
86+
///
87+
/// See [`VortexWriteOptions::exclude_dtype`] for details.
7888
pub fn exclude_dtype(mut self) -> Self {
7989
self.exclude_dtype = Some(true);
8090
self
@@ -85,14 +95,23 @@ impl VortexWriteOptionsFactory {
8595
self
8696
}
8797

98+
/// Configure which statistics to compute at the file-level.
99+
///
100+
/// See [`VortexWriteOptions::with_file_statistics`] for details.
88101
pub fn with_file_statistics(mut self, stats: Vec<Stat>) -> Self {
89102
self.file_statistics = Some(stats);
90103
self
91104
}
92105

106+
/// Build the [`VortexWriteOptions`] with the configured settings.
107+
///
108+
/// Finds an appropriate [`Handle`] automatically.
93109
pub fn build(&self) -> VortexWriteOptions {
94110
VortexWriteOptions {
95-
strategy: self.strategy.clone(),
111+
strategy: self
112+
.strategy
113+
.clone()
114+
.unwrap_or_else(|| WriteStrategyBuilder::new().build()),
96115
exclude_dtype: self.exclude_dtype.clone().unwrap_or(DEFAULT_EXCLUDE_DTYPE),
97116
max_variable_length_statistics_size: self
98117
.max_variable_length_statistics_size
@@ -102,7 +121,7 @@ impl VortexWriteOptionsFactory {
102121
.file_statistics
103122
.clone()
104123
.unwrap_or_else(|| DEFAULT_FILE_STATISTICS.to_vec()),
105-
handle: None,
124+
handle: Handle::find(),
106125
}
107126
}
108127
}

0 commit comments

Comments
 (0)