@@ -33,9 +33,14 @@ const DEFAULT_EXCLUDE_DTYPE: bool = false;
3333const DEFAULT_MAX_VARIABLE_LENGTH_STATISTICS_SIZE : usize = 64 ;
3434const 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 ) ]
3742pub 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 {
5762impl 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
6873impl 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