prashantwason commented on a change in pull request #3646:
URL: https://github.com/apache/hudi/pull/3646#discussion_r733328872



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/clean/CleanPlanner.java
##########
@@ -402,9 +478,16 @@ private String 
getLatestVersionBeforeCommit(List<FileSlice> fileSliceList, Hoodi
   public Option<HoodieInstant> getEarliestCommitToRetain() {
     Option<HoodieInstant> earliestCommitToRetain = Option.empty();
     int commitsRetained = config.getCleanerCommitsRetained();
+    int hoursRetained = config.getCleanerHoursRetained();
     if (config.getCleanerPolicy() == HoodieCleaningPolicy.KEEP_LATEST_COMMITS
         && commitTimeline.countInstants() > commitsRetained) {
-      earliestCommitToRetain = 
commitTimeline.nthInstant(commitTimeline.countInstants() - commitsRetained);
+      earliestCommitToRetain = 
commitTimeline.nthInstant(commitTimeline.countInstants() - commitsRetained); 
//15 instants total, 10 commits to retain, this gives 6th instant in the list
+    } else if (config.getCleanerPolicy() == 
HoodieCleaningPolicy.KEEP_LAST_X_HOURS) {
+      Instant instant = Instant.now();
+      ZonedDateTime commitDateTime = ZonedDateTime.ofInstant(instant, 
ZoneId.systemDefault());

Review comment:
       We should sync this to how the instant times are generated. 
   
   Another way to think about this could be:
   latestInstantTime = HoodieActiveTimeline.createNewInstantTime()
   earliestCommitToRetain = 
HoodieActiveTimeline.findInstantInPast(latestInstantTime, N); // N = number of 
hours in the past.
   
   Keeping the instant timestamp code together will prevent any surprises from 
a wrong time calculation cleaning data unintentionally.




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