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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/timeline/HoodieTimelineArchiver.java:
##########
@@ -362,6 +367,25 @@ private boolean deleteArchivedInstants(List<ActiveAction> 
activeActions, HoodieE
     return true;
   }
 
+  private Option<String> getEarliestCommitToNotArchive(HoodieActiveTimeline 
activeTimeline, HoodieTableMetaClient metaClient) throws IOException {
+    // if clean policy is based on file versions, earliest commit to not 
archive may not be set. So, we have to explicitly check the savepoint timeline
+    // and guard against the first one.
+    String earliestInstantToNotArchive = 
table.getCompletedSavepointTimeline().firstInstant().map(HoodieInstant::getTimestamp).orElse(null);
+    if (config.getCleanerPolicy() != 
HoodieCleaningPolicy.KEEP_LATEST_FILE_VERSIONS) {
+      Option<HoodieInstant> cleanInstantOpt =
+          
activeTimeline.getCleanerTimeline().filterCompletedInstants().lastInstant();
+      if (cleanInstantOpt.isPresent()) {
+        HoodieInstant cleanInstant = cleanInstantOpt.get();
+        String cleanerEarliestInstantToNotArchive = 
CleanerUtils.getCleanerPlan(metaClient, cleanInstant.isRequested()
+                ? cleanInstant
+                : 
HoodieTimeline.getCleanRequestedInstant(cleanInstant.getTimestamp()))
+            
.getExtraMetadata().getOrDefault(CleanPlanner.EARLIEST_COMMIT_TO_NOT_ARCHIVE, 
null);

Review Comment:
   getExtraMetadata() can return null and will NPE here. Check if the map 
exists before doing getOrDefault



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