SteNicholas commented on code in PR #7568: URL: https://github.com/apache/hudi/pull/7568#discussion_r1058196194
########## hudi-common/src/main/java/org/apache/hudi/common/util/ClusteringUtils.java: ########## @@ -224,4 +225,36 @@ public static List<HoodieInstant> getPendingClusteringInstantTimes(HoodieTableMe public static boolean isPendingClusteringInstant(HoodieTableMetaClient metaClient, HoodieInstant instant) { return getClusteringPlan(metaClient, instant).isPresent(); } + + /** + * Checks whether the latest clustering instant has a subsequent cleaning action. Returns + * the clustering instant if there is such cleaning action or empty. + * + * @param activeTimeline The active timeline + * @return the oldest instant to retain for clustering + */ + public static Option<HoodieInstant> getOldestInstantToRetainForClustering(HoodieActiveTimeline activeTimeline) + throws IOException { + Option<HoodieInstant> cleanInstantOpt = + activeTimeline.getCleanerTimeline().filter(instant -> !instant.isCompleted()).firstInstant(); + if (cleanInstantOpt.isPresent()) { + // The first clustering instant of which timestamp is greater than or equal to the earliest commit to retain of + // the clean metadata. Review Comment: @danny0405, +1, I have added the check whether the completed replace timeline is empty. -- 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