@@ -62,6 +62,8 @@ pub const DEFAULT_STATISTICS_TRUNCATE_LENGTH: Option<usize> = Some(64);
62
62
pub const DEFAULT_OFFSET_INDEX_DISABLED : bool = false ;
63
63
/// Default values for [`WriterProperties::coerce_types`]
64
64
pub const DEFAULT_COERCE_TYPES : bool = false ;
65
+ /// Default values for [`WriterProperties::internal_buffer_enabled`]
66
+ pub const DEFAULT_INTERNAL_BUFFER_ENABLE : bool = true ;
65
67
66
68
/// Parquet writer version.
67
69
///
@@ -169,6 +171,7 @@ pub struct WriterProperties {
169
171
column_index_truncate_length : Option < usize > ,
170
172
statistics_truncate_length : Option < usize > ,
171
173
coerce_types : bool ,
174
+ internal_buffer_enabled : bool ,
172
175
#[ cfg( feature = "encryption" ) ]
173
176
pub ( crate ) file_encryption_properties : Option < FileEncryptionProperties > ,
174
177
}
@@ -335,6 +338,13 @@ impl WriterProperties {
335
338
self . coerce_types
336
339
}
337
340
341
+ /// Returns `true` if internal buffer is enabled.
342
+ ///
343
+ /// For more details see [`WriterPropertiesBuilder::set_internal_buffer_enabled`]
344
+ pub fn internal_buffer_enabled ( & self ) -> bool {
345
+ self . internal_buffer_enabled
346
+ }
347
+
338
348
/// Returns encoding for a data page, when dictionary encoding is enabled.
339
349
///
340
350
/// This is not configurable.
@@ -458,6 +468,7 @@ pub struct WriterPropertiesBuilder {
458
468
column_index_truncate_length : Option < usize > ,
459
469
statistics_truncate_length : Option < usize > ,
460
470
coerce_types : bool ,
471
+ internal_buffer_enabled : bool ,
461
472
#[ cfg( feature = "encryption" ) ]
462
473
file_encryption_properties : Option < FileEncryptionProperties > ,
463
474
}
@@ -481,6 +492,7 @@ impl Default for WriterPropertiesBuilder {
481
492
column_index_truncate_length : DEFAULT_COLUMN_INDEX_TRUNCATE_LENGTH ,
482
493
statistics_truncate_length : DEFAULT_STATISTICS_TRUNCATE_LENGTH ,
483
494
coerce_types : DEFAULT_COERCE_TYPES ,
495
+ internal_buffer_enabled : DEFAULT_INTERNAL_BUFFER_ENABLE ,
484
496
#[ cfg( feature = "encryption" ) ]
485
497
file_encryption_properties : None ,
486
498
}
@@ -506,6 +518,7 @@ impl WriterPropertiesBuilder {
506
518
column_index_truncate_length : self . column_index_truncate_length ,
507
519
statistics_truncate_length : self . statistics_truncate_length ,
508
520
coerce_types : self . coerce_types ,
521
+ internal_buffer_enabled : self . internal_buffer_enabled ,
509
522
#[ cfg( feature = "encryption" ) ]
510
523
file_encryption_properties : self . file_encryption_properties ,
511
524
}
@@ -700,6 +713,21 @@ impl WriterPropertiesBuilder {
700
713
self
701
714
}
702
715
716
+ /// Enables an internal buffer to improve small write operations.
717
+ ///
718
+ /// If `true` (default), small writes will be collected into an internal
719
+ /// buffer before calling the underlying `Write::write` method. This is
720
+ /// essential for maintaining good performance when the underlying writer
721
+ /// is an I/O-sensitive sink (like a network socket or raw file handle).
722
+ ///
723
+ /// Buffering is often redundant and can be slightly less performant when
724
+ /// the underlying writer is already buffered (e.g., writing to a `Vec<u8>`
725
+ /// or a `std::io::BufWriter`). In such cases, this option can be set to `false`.
726
+ pub fn set_internal_buffer_enabled ( mut self , internal_buffer_enabled : bool ) -> Self {
727
+ self . internal_buffer_enabled = internal_buffer_enabled;
728
+ self
729
+ }
730
+
703
731
/// Sets FileEncryptionProperties (defaults to `None`)
704
732
#[ cfg( feature = "encryption" ) ]
705
733
pub fn with_file_encryption_properties (
@@ -958,6 +986,7 @@ impl From<WriterProperties> for WriterPropertiesBuilder {
958
986
sorting_columns : props. sorting_columns ,
959
987
column_index_truncate_length : props. column_index_truncate_length ,
960
988
statistics_truncate_length : props. statistics_truncate_length ,
989
+ internal_buffer_enabled : props. internal_buffer_enabled ,
961
990
coerce_types : props. coerce_types ,
962
991
#[ cfg( feature = "encryption" ) ]
963
992
file_encryption_properties : props. file_encryption_properties ,
0 commit comments