rdblue commented on code in PR #9384:
URL: https://github.com/apache/iceberg/pull/9384#discussion_r1439061281


##########
core/src/main/java/org/apache/iceberg/deletes/SortingPositionOnlyDeleteWriter.java:
##########
@@ -71,14 +83,44 @@ public DeleteWriteResult result() {
   @Override
   public void close() throws IOException {
     if (result == null) {
-      this.result = writeDeletes();
+      switch (granularity) {
+        case FILE:
+          this.result = writeFileDeletes();
+          return;
+        case PARTITION:
+          this.result = writePartitionDeletes();
+          return;
+        default:
+          throw new UnsupportedOperationException("Unsupported delete 
granularity: " + granularity);
+      }
     }
   }
 
-  private DeleteWriteResult writeDeletes() throws IOException {
+  // write deletes for all data files together
+  private DeleteWriteResult writePartitionDeletes() throws IOException {
+    return writeDeletes(positionsByPath.keySet());
+  }
+
+  // write deletes for different data files into distinct delete files
+  private DeleteWriteResult writeFileDeletes() throws IOException {
+    List<DeleteFile> deleteFiles = Lists.newArrayList();
+    CharSequenceSet referencedDataFiles = CharSequenceSet.empty();
+
+    for (CharSequence path : positionsByPath.keySet()) {
+      DeleteWriteResult writeResult = writeDeletes(ImmutableList.of(path));
+      deleteFiles.addAll(writeResult.deleteFiles());
+      referencedDataFiles.addAll(writeResult.referencedDataFiles());

Review Comment:
   Won't this be `positionsByPath.keySet()`?



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to