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


##########
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:
   `getEarliestCommitToNotArchive` is not a good name because all the logic in 
archiver is to compute the "earliest commit to not archive".



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