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


##########
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:
   Nit: It might be good to keep this comment, but using the named constants in 
the comment instead so that the behavior is still well spelled out for people. 
Or adding a short javadoc to the `ListDirsRecursively` flat map function class.



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