You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/12/29 17:47:26 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #2001: iss1980 a special close flag added to indicate that the writer is closed

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



##########
File path: parquet/src/test/java/org/apache/iceberg/parquet/ParquetWritingTestUtils.java
##########
@@ -53,20 +54,43 @@ static File writeRecords(TemporaryFolder temp, Schema schema,
   }
 
   static File writeRecords(
-      TemporaryFolder temp,
-      Schema schema, Map<String, String> properties,
-      Function<MessageType, ParquetValueWriter<?>> createWriterFunc,
-      GenericData.Record... records) throws IOException {
+          TemporaryFolder temp,
+          Schema schema, Map<String, String> properties,
+          Function<MessageType, ParquetValueWriter<?>> createWriterFunc,
+          GenericData.Record... records) throws IOException {
+    File file = createTempFile(temp);
+    write(file, schema, properties, createWriterFunc, records);
+    return file;
+  }
+
+  static long write(File file, Schema schema, Map<String, String> properties,
+                    Function<MessageType, ParquetValueWriter<?>> createWriterFunc,
+                    GenericData.Record... records) throws IOException {
+    FileAppender<GenericData.Record> writer = Parquet.write(localOutput(file))

Review comment:
       This should still use try-with-resources. You just have to keep a reference to the writer outside of it:
   
   ```java
     FileAppender<Record> writer = Parquet.write(...);
     try (Closeable toClose = writer) {
       writer.addAll(records);
     }
   
     writer.length();
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org