You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/04/11 00:57:21 UTC

[GitHub] [hudi] yihua commented on a diff in pull request #5261: [HUDI-3799] Fixing not deleting empty instants w/o archiving

yihua commented on code in PR #5261:
URL: https://github.com/apache/hudi/pull/5261#discussion_r846879376


##########
hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestTable.java:
##########
@@ -286,8 +286,8 @@ public HoodieTestTable addClean(String instantTime, HoodieCleanerPlan cleanerPla
   }
 
   public HoodieTestTable addClean(String instantTime, HoodieCleanerPlan cleanerPlan, HoodieCleanMetadata metadata, boolean isEmpty) throws IOException {
-    createRequestedCleanFile(basePath, instantTime, cleanerPlan, isEmpty);
-    createInflightCleanFile(basePath, instantTime, cleanerPlan, isEmpty);
+    createRequestedCleanFile(basePath, instantTime, cleanerPlan, false);
+    createInflightCleanFile(basePath, instantTime, cleanerPlan, false);

Review Comment:
   why changing this?



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/utils/MetadataConversionUtils.java:
##########
@@ -125,6 +125,46 @@ public static HoodieArchivedMetaEntry createMetaWrapper(HoodieInstant hoodieInst
     return archivedMetaWrapper;
   }
 
+  public static HoodieArchivedMetaEntry createMetaWrapperForEmptyInstant(HoodieInstant hoodieInstant) throws IOException {
+    HoodieArchivedMetaEntry archivedMetaWrapper = new HoodieArchivedMetaEntry();
+    archivedMetaWrapper.setCommitTime(hoodieInstant.getTimestamp());
+    archivedMetaWrapper.setActionState(hoodieInstant.getState().name());
+    switch (hoodieInstant.getAction()) {
+      case HoodieTimeline.CLEAN_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.clean.name());
+        break;
+      }
+      case HoodieTimeline.COMMIT_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.commit.name());
+        break;
+      }
+      case HoodieTimeline.DELTA_COMMIT_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.deltacommit.name());
+        break;
+      }
+      case HoodieTimeline.REPLACE_COMMIT_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.replacecommit.name());
+        break;
+      }
+      case HoodieTimeline.ROLLBACK_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.rollback.name());
+        break;
+      }
+      case HoodieTimeline.SAVEPOINT_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.savepoint.name());
+        break;
+      }
+      case HoodieTimeline.COMPACTION_ACTION: {
+        archivedMetaWrapper.setActionType(ActionType.compaction.name());

Review Comment:
   For some of these actions, we may still extract useful information from requested and inflight instant files.  For example, for compaction and clustering, we can extract the plan information.  This is not required for this PR and can be a follow-up.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/HoodieTimelineArchiver.java:
##########
@@ -632,8 +629,9 @@ private void writeToFile(Schema wrapperSchema, List<IndexedRecord> records) thro
     }
   }
 
-  private IndexedRecord convertToAvroRecord(HoodieInstant hoodieInstant)
+  private IndexedRecord convertToAvroRecord(HoodieInstant hoodieInstant, boolean isEmpty)

Review Comment:
   nit: given that the logic for empty instant is completely different, it's better to create a new method `createAvroRecordFromEmptyInstant()`.



-- 
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-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org