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 2022/08/11 21:15:23 UTC

[GitHub] [iceberg] kbendick commented on a diff in pull request #5495: Spark 3.3: Reduce serialization in DeleteOrphanFilesSparkAction

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

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