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



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/utils/MetadataConversionUtils.java
##########
@@ -105,14 +114,15 @@ 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<HoodieRequestedReplaceMetadata> 
getRequestedReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant 
pendingReplaceInstant) throws IOException {
+    final HoodieInstant requestedInstant = 
HoodieTimeline.getReplaceCommitRequestedInstant(pendingReplaceInstant.getTimestamp());
+
+    Option<byte[]> content = 
metaClient.getActiveTimeline().getInstantDetails(requestedInstant);
+    if (!content.isPresent() || content.get().length == 0) {
+      LOG.warn("No content found in requested file for instant " + 
pendingReplaceInstant);
+      return Option.of(new HoodieRequestedReplaceMetadata());

Review comment:
       I will try with what you suggested

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/utils/MetadataConversionUtils.java
##########
@@ -105,14 +114,15 @@ 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<HoodieRequestedReplaceMetadata> 
getRequestedReplaceMetadata(HoodieTableMetaClient metaClient, HoodieInstant 
pendingReplaceInstant) throws IOException {
+    final HoodieInstant requestedInstant = 
HoodieTimeline.getReplaceCommitRequestedInstant(pendingReplaceInstant.getTimestamp());
+
+    Option<byte[]> content = 
metaClient.getActiveTimeline().getInstantDetails(requestedInstant);
+    if (!content.isPresent() || content.get().length == 0) {
+      LOG.warn("No content found in requested file for instant " + 
pendingReplaceInstant);
+      return Option.of(new HoodieRequestedReplaceMetadata());

Review comment:
       Current logic is using `import 
org.apache.hudi.common.model.HoodieCommitMetadata.fromBytes()` to fetch empty 
deltacommit (bytes = []), and creating a new instance of metadata which bytes 
not empty. So I was thinking it may be better to keep same behaviour in 
ReplaceCommitRequestedInstant.




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