yuzelin commented on code in PR #852:
URL: https://github.com/apache/incubator-paimon/pull/852#discussion_r1161537469
##########
paimon-core/src/main/java/org/apache/paimon/operation/FileStoreExpireImpl.java:
##########
@@ -327,4 +353,39 @@ private void writeEarliestHint(long earliest) {
throw new RuntimeException(e);
}
}
+
+ private void tryDeletePartitionDirectories(Map<BinaryRow, Set<Integer>>
changedPartitions) {
+ Map<Integer, Set<Path>> deduplicate = new HashMap<>();
+ for (Map.Entry<BinaryRow, Set<Integer>> entry :
changedPartitions.entrySet()) {
+ for (Integer bucket : entry.getValue()) {
+ // try to delete bucket directories
+ tryDeleteDirectory(pathFactory.bucketPath(entry.getKey(),
bucket));
+ }
+ List<Path> hierarchicalPaths =
pathFactory.getHierarchicalPartitionPath(entry.getKey());
+ int pathNum = hierarchicalPaths.size();
+ if (pathNum > 0) {
+ // try to delete the deepest partition directory
+ tryDeleteDirectory(hierarchicalPaths.get(pathNum - 1));
+ // deduplicate high level partition directories
+ for (int hierarchy = 0; hierarchy < pathNum - 1; hierarchy++) {
+ deduplicate
+ .computeIfAbsent(hierarchy, i -> new HashSet<>())
+ .add(hierarchicalPaths.get(hierarchy));
+ }
+ }
+ }
+
+ // from deepest to shallowest
+ for (int hierarchy = deduplicate.size() - 1; hierarchy >= 0;
hierarchy--) {
+ deduplicate.get(hierarchy).forEach(this::tryDeleteDirectory);
Review Comment:
For each hierarchy in deduplicate, I have set a new HashSet. So the return
is at least an empty set.
--
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]