jackye1995 commented on code in PR #7914:
URL: https://github.com/apache/iceberg/pull/7914#discussion_r1242737798
##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/actions/DeleteOrphanFilesSparkAction.java:
##########
@@ -303,36 +303,50 @@ private Dataset<String> listedFileDS() {
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 MAX_DRIVER_LISTING_DEPTH levels and only dirs that have
- // less than MAX_DRIVER_LISTING_DIRECT_SUB_DIRS direct sub dirs on the
driver
- listDirRecursively(
- location,
- predicate,
- hadoopConf.value(),
- MAX_DRIVER_LISTING_DEPTH,
- MAX_DRIVER_LISTING_DIRECT_SUB_DIRS,
- subDirs,
- pathFilter,
- matchingFiles);
-
- JavaRDD<String> matchingFileRDD =
sparkContext().parallelize(matchingFiles, 1);
-
- if (subDirs.isEmpty()) {
+ if (table.io() instanceof SupportsPrefixOperations) {
+ Iterator<org.apache.iceberg.io.FileInfo> iterator =
((SupportsPrefixOperations) table.io()).listPrefix(location).iterator();
+ while (iterator.hasNext()) {
+ org.apache.iceberg.io.FileInfo fileInfo = iterator.next();
+ if (fileInfo.createdAtMillis() < olderThanTimestamp) {
+ matchingFiles.add(fileInfo.location());
+ }
+ }
+
+ JavaRDD<String> matchingFileRDD =
sparkContext().parallelize(matchingFiles, 1);
return spark().createDataset(matchingFileRDD.rdd(), Encoders.STRING());
- }
+ } else {
Review Comment:
I think we don't need to use else here, because the if case directly
returns. This should avoid many unnecessary diffs
--
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]