danny0405 commented on code in PR #7568:
URL: https://github.com/apache/hudi/pull/7568#discussion_r1058708529


##########
hudi-common/src/main/java/org/apache/hudi/common/util/ClusteringUtils.java:
##########
@@ -224,4 +225,37 @@ 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 {
+    HoodieTimeline replaceTimeline = 
activeTimeline.getCompletedReplaceTimeline();
+    if (!replaceTimeline.empty()) {
+      Option<HoodieInstant> cleanInstantOpt =
+          activeTimeline.getCleanerTimeline().filter(instant -> 
!instant.isCompleted()).firstInstant();

Review Comment:
   +1 with this part, although this is a weak ensurence.



-- 
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

Reply via email to