nsivabalan commented on code in PR #11440:
URL: https://github.com/apache/hudi/pull/11440#discussion_r1683633218


##########
hudi-common/src/main/java/org/apache/hudi/common/util/ClusteringUtils.java:
##########
@@ -365,20 +370,56 @@ public static Option<HoodieInstant> 
getEarliestInstantToRetainForClustering(
           // TODO: This case has to be handled. HUDI-6352
           retainLowerBound = cleanInstant.getTimestamp();
         }
-
-        oldestInstantToRetain = replaceOrClusterTimeline.filter(instant ->
-                HoodieTimeline.compareTimestamps(
-                    instant.getTimestamp(),
-                    HoodieTimeline.GREATER_THAN_OR_EQUALS,
-                    retainLowerBound))
-            .firstInstant();
+        oldestInstantToRetain = 
replaceOrClusterTimeline.findInstantsAfterOrEquals(retainLowerBound).firstInstant();
       } else {
         oldestInstantToRetain = replaceOrClusterTimeline.firstInstant();
       }
     }
+    if (!shouldArchiveBeyondSavepoint) {
+      // explicitly check the savepoint timeline and guard against the first 
one
+      Option<HoodieInstant> firstSavepointOpt = 
activeTimeline.getSavePointTimeline().filterCompletedInstants().firstInstant();
+      oldestInstantToRetain = 
Option.ofNullable(HoodieTimeline.minTimestampInstant(oldestInstantToRetain.orElse(null),
 firstSavepointOpt.orElse(null)));
+    }
     return oldestInstantToRetain;
   }
 
+  public static Option<String> 
getEarliestReplacedSavepointInClean(HoodieActiveTimeline activeTimeline, 
HoodieCleaningPolicy cleanerPolicy,

Review Comment:
   we can name this method as 
   getEarliestCommitToNotArchive. and keep this method in 
HoodieTimelineArchiver. 
   
   either we can compute and pass the value to 
ClusteringUtils.getEarliestInstantToRetainForClustering  or make a function as 
an arg. 



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