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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieArchivedTimeline.java:
##########
@@ -184,203 +222,327 @@ public HoodieArchivedTimeline reload() {
     return new HoodieArchivedTimeline(metaClient);
   }
 
-  private HoodieInstant readCommit(GenericRecord record, boolean loadDetails) {
-    final String instantTime = 
record.get(HoodiePartitionMetadata.COMMIT_TIME_KEY).toString();
-    final String action = record.get(ACTION_TYPE_KEY).toString();
-    final String stateTransitionTime = (String) 
record.get(STATE_TRANSITION_TIME);
-    if (loadDetails) {
-      getMetadataKey(action).map(key -> {
-        Object actionData = record.get(key);
-        if (actionData != null) {
-          if (action.equals(HoodieTimeline.COMPACTION_ACTION)) {
-            this.readCommits.put(instantTime, 
HoodieAvroUtils.indexedRecordToBytes((IndexedRecord) actionData));
-          } else {
-            this.readCommits.put(instantTime, 
actionData.toString().getBytes(StandardCharsets.UTF_8));
-          }
+  private HoodieInstant readCommit(GenericRecord record, LoadMode loadMode) {
+    final String instantTime = 
record.get(INSTANT_TIME_ARCHIVED_META_FIELD).toString();
+    final String action = record.get(ACTION_ARCHIVED_META_FIELD).toString();
+    final String completionTime = 
record.get(COMPLETION_TIME_ARCHIVED_META_FIELD).toString();
+    loadInstantDetails(record, instantTime, loadMode);
+    return new HoodieInstant(HoodieInstant.State.COMPLETED, action, 
instantTime, completionTime);
+  }
+
+  private void loadInstantDetails(GenericRecord record, String instantTime, 
LoadMode loadMode) {
+    switch (loadMode) {
+      case COMMIT_META:
+        ByteBuffer commitMeta = (ByteBuffer) 
record.get(METADATA_ARCHIVED_META_FIELD);
+        if (commitMeta != null) {
+          // in case the entry comes from an empty completed meta file
+          this.readCommits.put(instantTime, commitMeta.array());
         }
-        return null;
-      });
-    }
-    return new 
HoodieInstant(HoodieInstant.State.valueOf(record.get(ACTION_STATE).toString()), 
action,
-        instantTime, stateTransitionTime);
-  }
-
-  @Nonnull
-  private Option<String> getMetadataKey(String action) {
-    switch (action) {
-      case HoodieTimeline.CLEAN_ACTION:
-        return Option.of("hoodieCleanMetadata");
-      case HoodieTimeline.COMMIT_ACTION:
-      case HoodieTimeline.DELTA_COMMIT_ACTION:
-        return Option.of("hoodieCommitMetadata");
-      case HoodieTimeline.ROLLBACK_ACTION:
-        return Option.of("hoodieRollbackMetadata");
-      case HoodieTimeline.SAVEPOINT_ACTION:
-        return Option.of("hoodieSavePointMetadata");
-      case HoodieTimeline.COMPACTION_ACTION:
-      case HoodieTimeline.LOG_COMPACTION_ACTION:
-        return Option.of("hoodieCompactionPlan");
-      case HoodieTimeline.REPLACE_COMMIT_ACTION:
-        return Option.of("hoodieReplaceCommitMetadata");
-      case HoodieTimeline.INDEXING_ACTION:
-        return Option.of("hoodieIndexCommitMetadata");
+        break;
+      case PLAN:
+        ByteBuffer plan = (ByteBuffer) record.get(PLAN_ARCHIVED_META_FIELD);
+        if (plan != null) {

Review Comment:
   Yeah, the plan is only useful for CLI presentation now.



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