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/12/08 23:16:25 UTC
[GitHub] [iceberg] rdblue commented on a diff in pull request #6090: Core: Handle statistics file clean up from expireSnapshots
rdblue commented on code in PR #6090:
URL: https://github.com/apache/iceberg/pull/6090#discussion_r1043910826
##########
core/src/main/java/org/apache/iceberg/FileCleanupStrategy.java:
##########
@@ -83,4 +85,33 @@ protected void deleteFiles(Set<String> pathsToDelete, String fileType) {
(file, thrown) -> LOG.warn("Delete failed for {} file: {}", fileType, file, thrown))
.run(deleteFunc::accept);
}
+
+ protected Set<String> expiredStatisticsFilesLocations(
+ TableMetadata beforeExpiration, Set<Long> validIds, Set<Long> expiredIds) {
+ Set<String> validStatisticsFilesLocation = Sets.newHashSet();
+ for (long snapshotId : validIds) {
+ List<StatisticsFile> statisticsFiles =
+ beforeExpiration.statisticsFilesForSnapshot(snapshotId);
+ if (statisticsFiles != null) {
+ statisticsFiles.forEach(file -> validStatisticsFilesLocation.add(file.path()));
+ }
+ }
+
+ // Statistics files can be reused in case of rewrite data files.
+ // Hence, filter out the reachable/valid statistics files.
+ Set<String> expiredStatisticsFilesLocations = Sets.newHashSet();
+ for (long snapshotId : expiredIds) {
+ List<StatisticsFile> statisticsFiles =
+ beforeExpiration.statisticsFilesForSnapshot(snapshotId);
+ if (statisticsFiles != null) {
+ statisticsFiles.forEach(
+ file -> {
+ if (!validStatisticsFilesLocation.contains(file.path())) {
+ expiredStatisticsFilesLocations.add(file.path());
+ }
+ });
+ }
+ }
+ return expiredStatisticsFilesLocations;
Review Comment:
Style: missing whitespace.
--
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