@@ -62,6 +62,8 @@ pub const DEFAULT_STATISTICS_TRUNCATE_LENGTH: Option<usize> = Some(64);
6262pub const DEFAULT_OFFSET_INDEX_DISABLED : bool = false ;
6363/// Default values for [`WriterProperties::coerce_types`]
6464pub const DEFAULT_COERCE_TYPES : bool = false ;
65+ /// Default values for [`WriterProperties::internal_buffer_enabled`]
66+ pub const DEFAULT_INTERNAL_BUFFER_ENABLE : bool = true ;
6567
6668/// Parquet writer version.
6769///
@@ -169,6 +171,7 @@ pub struct WriterProperties {
169171 column_index_truncate_length : Option < usize > ,
170172 statistics_truncate_length : Option < usize > ,
171173 coerce_types : bool ,
174+ internal_buffer_enabled : bool ,
172175 #[ cfg( feature = "encryption" ) ]
173176 pub ( crate ) file_encryption_properties : Option < FileEncryptionProperties > ,
174177}
@@ -335,6 +338,13 @@ impl WriterProperties {
335338 self . coerce_types
336339 }
337340
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+
338348 /// Returns encoding for a data page, when dictionary encoding is enabled.
339349 ///
340350 /// This is not configurable.
@@ -458,6 +468,7 @@ pub struct WriterPropertiesBuilder {
458468 column_index_truncate_length : Option < usize > ,
459469 statistics_truncate_length : Option < usize > ,
460470 coerce_types : bool ,
471+ internal_buffer_enabled : bool ,
461472 #[ cfg( feature = "encryption" ) ]
462473 file_encryption_properties : Option < FileEncryptionProperties > ,
463474}
@@ -481,6 +492,7 @@ impl Default for WriterPropertiesBuilder {
481492 column_index_truncate_length : DEFAULT_COLUMN_INDEX_TRUNCATE_LENGTH ,
482493 statistics_truncate_length : DEFAULT_STATISTICS_TRUNCATE_LENGTH ,
483494 coerce_types : DEFAULT_COERCE_TYPES ,
495+ internal_buffer_enabled : DEFAULT_INTERNAL_BUFFER_ENABLE ,
484496 #[ cfg( feature = "encryption" ) ]
485497 file_encryption_properties : None ,
486498 }
@@ -506,6 +518,7 @@ impl WriterPropertiesBuilder {
506518 column_index_truncate_length : self . column_index_truncate_length ,
507519 statistics_truncate_length : self . statistics_truncate_length ,
508520 coerce_types : self . coerce_types ,
521+ internal_buffer_enabled : self . internal_buffer_enabled ,
509522 #[ cfg( feature = "encryption" ) ]
510523 file_encryption_properties : self . file_encryption_properties ,
511524 }
@@ -700,6 +713,21 @@ impl WriterPropertiesBuilder {
700713 self
701714 }
702715
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+
703731 /// Sets FileEncryptionProperties (defaults to `None`)
704732 #[ cfg( feature = "encryption" ) ]
705733 pub fn with_file_encryption_properties (
@@ -958,6 +986,7 @@ impl From<WriterProperties> for WriterPropertiesBuilder {
958986 sorting_columns : props. sorting_columns ,
959987 column_index_truncate_length : props. column_index_truncate_length ,
960988 statistics_truncate_length : props. statistics_truncate_length ,
989+ internal_buffer_enabled : props. internal_buffer_enabled ,
961990 coerce_types : props. coerce_types ,
962991 #[ cfg( feature = "encryption" ) ]
963992 file_encryption_properties : props. file_encryption_properties ,
0 commit comments