aokolnychyi commented on code in PR #5495:
URL: https://github.com/apache/iceberg/pull/5495#discussion_r944041996


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/actions/DeleteOrphanFilesSparkAction.java:
##########
@@ -256,41 +256,62 @@ private DeleteOrphanFiles.Result doExecute() {
     return new BaseDeleteOrphanFilesActionResult(orphanFiles);
   }
 
-  private Dataset<Row> buildValidFileDF() {
-    return contentFileDS(table)
-        .union(manifestDS(table))
-        .union(manifestListDS(table))
-        .union(otherMetadataFileDS(table))
-        .toDF(FILE_PATH, FILE_TYPE)
-        .select(FILE_PATH);
+  private Dataset<FileURI> validFileIdentDS() {
+    // apply the transformation before union to avoid extra serialization
+    FileInfoToFileURI toURI = new FileInfoToFileURI(equalSchemes, 
equalAuthorities);
+
+    Dataset<FileURI> contentFileIdentDS = toURI.apply(contentFileDS(table));
+    Dataset<FileURI> manifestFileIdentDS = toURI.apply(manifestDS(table));
+    Dataset<FileURI> manifestListIdentDS = toURI.apply(manifestListDS(table));
+    Dataset<FileURI> otherMetadataFileIdentDS = 
toURI.apply(otherMetadataFileDS(table));
+
+    return contentFileIdentDS
+        .union(manifestFileIdentDS)
+        .union(manifestListIdentDS)
+        .union(otherMetadataFileIdentDS);
   }
 
-  private Dataset<Row> buildActualFileDF() {
+  private Dataset<FileURI> actualFileIdentDS() {
+    StringToFileURI toURI = new StringToFileURI(equalSchemes, 
equalAuthorities);
+    if (compareToFileList == null) {
+      return toURI.apply(actualFileDS());
+    } else {
+      return toURI.apply(filteredCompareToFileList());
+    }
+  }
+
+  private Dataset<String> actualFileDS() {
     List<String> subDirs = Lists.newArrayList();
     List<String> matchingFiles = Lists.newArrayList();
 
     Predicate<FileStatus> predicate = file -> file.getModificationTime() < 
olderThanTimestamp;
     PathFilter pathFilter = 
PartitionAwareHiddenPathFilter.forSpecs(table.specs());
 
-    // list at most 3 levels and only dirs that have less than 10 direct sub 
dirs on the driver

Review Comment:
   Sounds good. Will do.



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