rdblue commented on a change in pull request #1213:
URL: https://github.com/apache/iceberg/pull/1213#discussion_r463347911



##########
File path: core/src/main/java/org/apache/iceberg/io/UnpartitionedWriter.java
##########
@@ -17,24 +17,42 @@
  * under the License.
  */
 
-package org.apache.iceberg.spark.source;
+package org.apache.iceberg.io;
 
 import java.io.IOException;
 import org.apache.iceberg.FileFormat;
 import org.apache.iceberg.PartitionSpec;
-import org.apache.iceberg.io.FileIO;
-import org.apache.spark.sql.catalyst.InternalRow;
 
-class UnpartitionedWriter extends BaseWriter {
-  UnpartitionedWriter(PartitionSpec spec, FileFormat format, 
SparkAppenderFactory appenderFactory,
-                      OutputFileFactory fileFactory, FileIO io, long 
targetFileSize) {
+public class UnpartitionedWriter<T> extends BaseTaskWriter<T> {
+
+  private RollingFileWriter currentWriter = null;
+
+  public UnpartitionedWriter(PartitionSpec spec, FileFormat format, 
FileAppenderFactory<T> appenderFactory,
+                             OutputFileFactory fileFactory, FileIO io, long 
targetFileSize) {
     super(spec, format, appenderFactory, fileFactory, io, targetFileSize);
+  }
 
-    openCurrent();
+  @Override
+  public void write(T record) throws IOException {
+    if (currentWriter == null) {
+      currentWriter = new RollingFileWriter(null);
+    }
+    currentWriter.add(record);
   }
 
   @Override
-  public void write(InternalRow row) throws IOException {
-    writeInternal(row);
+  public void close() throws IOException {
+    closeCurrent();
+  }
+
+  private void closeCurrent() throws IOException {

Review comment:
       Is this method needed? Why not merge it with `close`?




----------------------------------------------------------------
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.

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