pratyakshsharma commented on a change in pull request #4385:
URL: https://github.com/apache/hudi/pull/4385#discussion_r782934576



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/clean/CleanPlanActionExecutor.java
##########
@@ -58,8 +59,34 @@ public CleanPlanActionExecutor(HoodieEngineContext context,
     this.extraMetadata = extraMetadata;
   }
 
-  protected Option<HoodieCleanerPlan> createCleanerPlan() {
-    return execute();
+  private int getCommitInfo() {
+    Option<HoodieInstant> lastCleanInstant = 
table.getActiveTimeline().getCleanerTimeline().filterCompletedInstants().lastInstant();
+    HoodieTimeline commitTimeline = 
table.getActiveTimeline().getCommitTimeline().filterCompletedInstants();
+
+    String latestCleanTs;
+    int commitsSinceLastCleaning = 0;
+    if (lastCleanInstant.isPresent()) {
+      latestCleanTs = lastCleanInstant.get().getTimestamp();
+      commitsSinceLastCleaning = 
commitTimeline.findInstantsAfter(latestCleanTs).countInstants();
+    } else {
+      String firstCommitTs = 
commitTimeline.firstInstant().get().getTimestamp();
+      commitsSinceLastCleaning = 
commitTimeline.findInstantsAfterOrEquals(firstCommitTs, 
Integer.MAX_VALUE).countInstants();
+    }
+
+    return commitsSinceLastCleaning;
+  }
+
+  private boolean needCleaning(CleaningTriggerStrategy strategy) {
+    boolean cleaningNeeded;
+    if (strategy == CleaningTriggerStrategy.NUM_COMMITS) {
+      int numberOfCommits = getCommitInfo();
+      int maxInlineCommitsForNextClean = config.getInlineCleaningMaxCommits();
+      cleaningNeeded = numberOfCommits >= maxInlineCommitsForNextClean;

Review comment:
       right.




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