CTTY commented on code in PR #1657:
URL: https://github.com/apache/iceberg-rust/pull/1657#discussion_r2388942753


##########
crates/iceberg/src/writer/file_writer/rolling_writer.rs:
##########
@@ -15,67 +15,121 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use std::fmt::{Debug, Formatter};
+
 use arrow_array::RecordBatch;
 
-use crate::spec::DataFileBuilder;
+use crate::io::{FileIO, OutputFile};
+use crate::spec::{DataFileBuilder, 
PROPERTY_WRITE_TARGET_FILE_SIZE_BYTES_DEFAULT, PartitionKey};
 use crate::writer::CurrentFileStatus;
+use crate::writer::file_writer::location_generator::{FileNameGenerator, 
LocationGenerator};
 use crate::writer::file_writer::{FileWriter, FileWriterBuilder};
 use crate::{Error, ErrorKind, Result};
 
-/// Builder for creating a `RollingFileWriter` that rolls over to a new file
-/// when the data size exceeds a target threshold.
-#[derive(Clone)]
-pub struct RollingFileWriterBuilder<B: FileWriterBuilder> {
+/// A writer that automatically rolls over to a new file when the data size
+/// exceeds a target threshold.
+///
+/// This writer wraps another file writer that tracks the amount of data 
written.
+/// When the data size exceeds the target size, it closes the current file and
+/// starts writing to a new one.
+pub struct RollingFileWriter<B: FileWriterBuilder, L: LocationGenerator, F: 
FileNameGenerator> {
+    inner: Option<B::R>,
     inner_builder: B,
     target_file_size: usize,
+    data_file_builders: Vec<DataFileBuilder>,
+    file_io: FileIO,
+    location_generator: L,
+    file_name_generator: F,
+}
+
+impl<B: FileWriterBuilder, L: LocationGenerator, F: FileNameGenerator> Clone

Review Comment:
   Having `Clone` can be useful in the upcoming `PartitioningWriter` level when 
we need to spawn new writers with the same configuration. for example, if we 
have a fanout partitioning writer, and we will need to create a new writer 
whenever there is a new partition coming in. 
   
   With `Clone`, it would be simple:
   ```rust
   let new_writer = self.iceberg_writer_builder.clone().build()?; // 
iceberg_writer can be generic type
   ```
   Without `Clone`, we will need to re-populate the `IcebergWriterBuilder` and 
the inner writers all over again:
   ```rust
   let parquet_writer = ...;
   let new_rolling_writer = RollingFileWriter::new(parquet_writer, /* pass down 
objs like file_io, target_file_size... */);
   let iceberg_writer_builder = DataFileWriterBuilder::new(...); // this has to 
be concrete type
   let new_writer = iceberg_writer_builder.build()?;
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to