aokolnychyi commented on code in PR #5495:
URL: https://github.com/apache/iceberg/pull/5495#discussion_r942999250
##########
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);
Review Comment:
I had to apply these transforms on each dataset before union to avoid the
unnecessary serialization/deserialization.
Here what we had before this change (String -> UTF8String -> UNION -> String
-> UTF8String:
```
+- SerializeFromObject [staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileMetadata,
true]).getAuthority, true, false, true) AS authority#148, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileMetadata,
true]).getLocation, true, false, true) AS location#149, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileMetadata,
true]).getPath, true, false, true) AS path#150, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileMetadata,
true]).getScheme, true, false, true) AS scheme#151]
+- MapPartitions
org.apache.spark.sql.Dataset$$Lambda$2741/0x0000000801747840@4acdc330, obj#147:
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileMetadata
+- DeserializeToObject createexternalrow(file_path#120.toString,
StructField(file_path,StringType,true)), obj#146: org.apache.spark.sql.Row
+- Union
:- Project [path#62 AS file_path#120]
: +- SerializeFromObject [staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0, org.apache.iceberg.spark.actions.FileInfo,
true]).getPath, true, false, true) AS path#62]
: +- MapPartitions
org.apache.spark.sql.Dataset$$Lambda$2672/0x000000080170d840@79ee7d2e, obj#61:
org.apache.iceberg.spark.actions.FileInfo
```
This is what we have now (two back to back `MapPartitions` without ser/des):
```
+- Union
:- Project [named_struct(authority, authority#81, path, path#82, scheme,
scheme#83, valueAsString, valueAsString#84) AS _2#170]
: +- Filter isnotnull(path#82)
: +- SerializeFromObject [staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileURI,
true]).getAuthority, true, false, true) AS authority#81, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileURI,
true]).getPath, true, false, true) AS path#82, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileURI,
true]).getScheme, true, false, true) AS scheme#83, staticinvoke(class
org.apache.spark.unsafe.types.UTF8String, StringType, fromString,
assertnotnull(input[0,
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileURI,
true]).getValueAsString, true, false, true) AS valueAsString#84]
: +- MapPartitions
org.apache.spark.sql.Dataset$$Lambda$2650/0x00000008016ef040@22cdc378, obj#80:
org.apache.iceberg.spark.actions.DeleteOrphanFilesSparkAction$FileURI
: +- MapPartitions
org.apache.spark.sql.Dataset$$Lambda$2703/0x000000080171c840@593ed55b, obj#76:
org.apache.iceberg.spark.actions.FileInfo
```
--
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]