codope commented on code in PR #12250:
URL: https://github.com/apache/hudi/pull/12250#discussion_r1842442211


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/upgrade/UpgradeDowngradeUtils.java:
##########
@@ -107,4 +132,95 @@ static void updateMetadataTableVersion(HoodieEngineContext 
context, HoodieTableV
       throw new HoodieIOException("Error while updating metadata table 
version", e);
     }
   }
+
+  static void upgradeToLSMTimeline(HoodieTable table, HoodieEngineContext 
engineContext, HoodieWriteConfig config) {
+    // migrate archived timeline
+    LSMTimelineWriter lsmTimelineWriter = 
LSMTimelineWriter.getInstance(config, table);
+    HoodieArchivedTimeline archivedTimeline = 
table.getMetaClient().getArchivedTimeline();
+    Consumer<Exception> exceptionHandler = e -> {
+      if (config.isFailOnTimelineArchivingEnabled()) {
+        throw new HoodieException(e);
+      }
+    };
+    
lsmTimelineWriter.write(Collections.singletonList(ActiveAction.fromInstants(archivedTimeline.getInstants())),
+        Option.of(action -> deleteAnyLeftOverMarkers(table, engineContext, 
config, action)), Option.of(exceptionHandler));
+  }
+
+  static void downgradeFromLSMTimeline(HoodieTable table, HoodieEngineContext 
engineContext, HoodieWriteConfig config) {
+    HoodieArchivedTimeline lsmArchivedTimeline = 
table.getMetaClient().getArchivedTimeline();
+
+    Consumer<Exception> exceptionHandler = e -> {
+      if (config.isFailOnTimelineArchivingEnabled()) {
+        throw new HoodieException("Failed to downgrade LSM timeline to old 
archived format", e);
+      }
+    };
+
+    // Migrate the LSM timeline back to the old archived timeline format
+    try {
+      // TODO: Convert instants from the LSM format to the old format

Review Comment:
   Ack. For now, i've ported over some legacy archiver code (copied from 
#11923) for local testing. Once that PR lands, I will rebase.



-- 
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: [email protected]

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

Reply via email to