lw309637554 commented on a change in pull request #2784:
URL: https://github.com/apache/hudi/pull/2784#discussion_r615500929



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/utils/MetadataConversionUtils.java
##########
@@ -105,14 +117,25 @@ public static HoodieArchivedMetaEntry 
createMetaWrapper(HoodieInstant hoodieInst
     return archivedMetaWrapper;
   }
 
-  public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant 
hoodieInstant,
-                                                          HoodieCommitMetadata 
hoodieCommitMetadata) {
-    HoodieArchivedMetaEntry archivedMetaWrapper = new 
HoodieArchivedMetaEntry();
-    archivedMetaWrapper.setCommitTime(hoodieInstant.getTimestamp());
-    archivedMetaWrapper.setActionState(hoodieInstant.getState().name());
-    
archivedMetaWrapper.setHoodieCommitMetadata(convertCommitMetadata(hoodieCommitMetadata));
-    archivedMetaWrapper.setActionType(ActionType.commit.name());
-    return archivedMetaWrapper;
+  public static Option<HoodieCommitMetadata> 
getInflightReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant 
instant) throws IOException {

Review comment:
       can we move this to ClusteringUtils

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/utils/MetadataConversionUtils.java
##########
@@ -105,14 +117,25 @@ public static HoodieArchivedMetaEntry 
createMetaWrapper(HoodieInstant hoodieInst
     return archivedMetaWrapper;
   }
 
-  public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant 
hoodieInstant,
-                                                          HoodieCommitMetadata 
hoodieCommitMetadata) {
-    HoodieArchivedMetaEntry archivedMetaWrapper = new 
HoodieArchivedMetaEntry();
-    archivedMetaWrapper.setCommitTime(hoodieInstant.getTimestamp());
-    archivedMetaWrapper.setActionState(hoodieInstant.getState().name());
-    
archivedMetaWrapper.setHoodieCommitMetadata(convertCommitMetadata(hoodieCommitMetadata));
-    archivedMetaWrapper.setActionType(ActionType.commit.name());
-    return archivedMetaWrapper;
+  public static Option<HoodieCommitMetadata> 
getInflightReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant 
instant) throws IOException {
+    Option<byte[]> inflightContent = 
metaClient.getActiveTimeline().getInstantDetails(instant);
+    if (!inflightContent.isPresent() || inflightContent.get().length == 0) {
+      // inflight files can be empty in some certain cases, e.g. when users 
opt in clustering
+      return Option.empty();
+    }
+    return Option.of(HoodieCommitMetadata.fromBytes(inflightContent.get(), 
HoodieCommitMetadata.class));
+  }
+
+  public static Option<HoodieRequestedReplaceMetadata> 
getRequestedReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant 
instant) throws IOException {

Review comment:
       can we move this to ClusteringUtils




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to