SteNicholas commented on code in PR #7405: URL: https://github.com/apache/hudi/pull/7405#discussion_r1057490946
########## hudi-common/src/main/java/org/apache/hudi/common/util/CleanerUtils.java: ########## @@ -161,4 +163,42 @@ public static void rollbackFailedWrites(HoodieFailedWritesCleaningPolicy cleanin throw new IllegalArgumentException("Unsupported action type " + actionType); } } + + /** + * Get latest clean planner clean time. + * @param metaClient + * @return Latest clean planner clean time. + * @throws IOException + */ + public static Option<String> getLatestInstantCleanTime(HoodieTableMetaClient metaClient) + throws IOException { + HoodieActiveTimeline activeTimeline = metaClient.getActiveTimeline(); + Option<HoodieInstant> lastCleanInstantOption = activeTimeline.getCleanerTimeline().lastInstant(); + Option<HoodieCleanMetadata> cleanMetadata = lastCleanInstantOption.isPresent() && ! activeTimeline.isEmpty(lastCleanInstantOption.get()) + ? Option.ofNullable(TimelineMetadataUtils.deserializeHoodieCleanMetadata(activeTimeline.getInstantDetails(lastCleanInstantOption.get()).get())) + : Option.empty(); + return cleanMetadata.isPresent() ? Option.ofNullable(cleanMetadata.get().getStartCleanTime()) : Option.empty(); + } + + /** + * Get earliest unClean completed instant + * @param metaClient + * @return + * @throws IOException + */ + public static Option<HoodieInstant> getEarliestUnCleanCompletedInstant(HoodieTableMetaClient metaClient) throws IOException { + Option<String> earliestInstantCleanTime = getLatestInstantCleanTime(metaClient); + HoodieActiveTimeline activeTimeline = metaClient.getActiveTimeline(); + Option<HoodieInstant> firstCompletedClusteringInstant = activeTimeline.getCommitsTimeline().filterCompletedInstants() + .filter(hoodieInstant -> hoodieInstant.getAction().equals(HoodieTimeline.REPLACE_COMMIT_ACTION)).firstInstant(); + if (!firstCompletedClusteringInstant.isPresent()) { Review Comment: If the firstCompletedClusteringInstant isn't present, it's no need to get the latest clean time from the clean metadata. -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org