gszadovszky commented on code in PR #3351:
URL: https://github.com/apache/parquet-java/pull/3351#discussion_r2459861196


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java:
##########
@@ -1812,22 +1813,35 @@ public void end(Map<String, String> extraMetaData) 
throws IOException {
       LOG.debug("{}: end", out.getPos());
       this.footer = new ParquetMetadata(new FileMetaData(schema, 
extraMetaData, Version.FULL_VERSION), blocks);
       serializeFooter(footer, out, fileEncryptor, metadataConverter);
+    } catch (IOException e) {
+      abort();
+      throw e;
     } finally {
       close();
     }
   }
 
+  /* Mark the writer as aborted to avoid flushing incomplete data to the 
cloud. */

Review Comment:
   nit: "to the cloud" is not required. That is only one use-case.



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java:
##########
@@ -1812,22 +1813,35 @@ public void end(Map<String, String> extraMetaData) 
throws IOException {
       LOG.debug("{}: end", out.getPos());
       this.footer = new ParquetMetadata(new FileMetaData(schema, 
extraMetaData, Version.FULL_VERSION), blocks);
       serializeFooter(footer, out, fileEncryptor, metadataConverter);
+    } catch (IOException e) {
+      abort();
+      throw e;
     } finally {
       close();
     }
   }
 
+  /* Mark the writer as aborted to avoid flushing incomplete data to the 
cloud. */
+  public void abort() {
+    aborted = true;
+  }
+
   @Override
   public void close() throws IOException {
     if (closed) {
       return;
     }
-    try (PositionOutputStream temp = out) {
-      temp.flush();
+
+    try {
+      if (!aborted && out != null) {
+        out.flush();
+      }
+    } catch (IOException e) {
+      throw e;

Review Comment:
   This is not required.



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