satishkotha commented on a change in pull request #2048:
URL: https://github.com/apache/hudi/pull/2048#discussion_r481365985
##########
File path:
hudi-client/src/main/java/org/apache/hudi/table/HoodieTimelineArchiveLog.java
##########
@@ -301,6 +304,44 @@ private void deleteAnyLeftOverMarkerFiles(JavaSparkContext
jsc, HoodieInstant in
}
}
+ private void deleteReplacedFiles(HoodieInstant instant) {
+ if (!instant.isCompleted()) {
+ // only delete files for completed instants
+ return;
+ }
+ Option<HoodieInstant> replaceInstantOption =
metaClient.getActiveTimeline().getCompletedAndReplaceTimeline()
+ .filter(replaceInstant ->
replaceInstant.getTimestamp().equals(instant.getTimestamp())).firstInstant();
+
+ replaceInstantOption.ifPresent(replaceInstant -> {
+ try {
+ HoodieCommitMetadata metadata = HoodieCommitMetadata.fromBytes(
+
metaClient.getActiveTimeline().getInstantDetails(replaceInstant).get(),
+ HoodieCommitMetadata.class);
+
+
metadata.getPartitionToReplaceStats().entrySet().stream().forEach(entry ->
+ deleteFileGroups(entry.getKey(), entry.getValue().stream().map(e
-> e.getFileId()).collect(Collectors.toSet()), instant)
+ );
+ } catch (IOException e) {
+ throw new HoodieCommitException("Failed to archive because cannot
delete replace files", e);
+ }
+ });
+ }
+
+ private void deleteFileGroups(String partitionPath, Set<String>
fileIdsToDelete, HoodieInstant instant) {
+ try {
+ FileStatus[] statuses =
metaClient.getFs().listStatus(FSUtils.getPartitionPath(metaClient.getBasePath(),
partitionPath));
Review comment:
Modified to use FileSystemViews
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]