zhuanshenbsj1 commented on code in PR #7405:
URL: https://github.com/apache/hudi/pull/7405#discussion_r1057525507


##########
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:
   Move it behind else.



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

Reply via email to