You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by vh...@apache.org on 2025/12/16 06:19:05 UTC

(hudi) branch master updated: refactor: Remove unnecessary utils in FileCreateUtils (#17593)

This is an automated email from the ASF dual-hosted git repository.

vhs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new 787634edcb5e refactor: Remove unnecessary utils in FileCreateUtils (#17593)
787634edcb5e is described below

commit 787634edcb5eae91b2d655090170aa35d8a5a326
Author: Y Ethan Guo <et...@gmail.com>
AuthorDate: Mon Dec 15 22:18:58 2025 -0800

    refactor: Remove unnecessary utils in FileCreateUtils (#17593)
---
 .../hudi/common/testutils/FileCreateUtils.java     | 27 ++++++----------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/hudi-common/src/test/java/org/apache/hudi/common/testutils/FileCreateUtils.java b/hudi-common/src/test/java/org/apache/hudi/common/testutils/FileCreateUtils.java
index d484876a1b4a..03be4951be1b 100644
--- a/hudi-common/src/test/java/org/apache/hudi/common/testutils/FileCreateUtils.java
+++ b/hudi-common/src/test/java/org/apache/hudi/common/testutils/FileCreateUtils.java
@@ -43,13 +43,12 @@ import org.apache.hudi.common.table.view.HoodieTableFileSystemView;
 import org.apache.hudi.common.table.view.TableFileSystemView;
 import org.apache.hudi.common.util.Option;
 import org.apache.hudi.exception.HoodieException;
-import org.apache.hudi.exception.HoodieIOException;
 import org.apache.hudi.storage.HoodieInstantWriter;
 import org.apache.hudi.storage.HoodieStorage;
 import org.apache.hudi.storage.StoragePath;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.RandomAccessFile;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -299,11 +298,6 @@ public class FileCreateUtils extends FileCreateUtilsBase {
     createMetaFile(metaClient, instantTime, HoodieTimeline.REQUESTED_ROLLBACK_EXTENSION, Option.of(plan));
   }
 
-  public static void createRequestedRollbackFile(HoodieTableMetaClient metaClient, String instantTime, byte[] content) throws IOException {
-    createMetaFileInTimelinePath(metaClient, instantTime, InProcessTimeGenerator::createNewInstantTime, HoodieTimeline.REQUESTED_ROLLBACK_EXTENSION,
-        Option.of(HoodieInstantWriter.convertByteArrayToWriter(content)));
-  }
-
   public static void createRequestedRollbackFile(HoodieTableMetaClient metaClient, String instantTime) throws IOException {
     createMetaFile(metaClient, instantTime, HoodieTimeline.REQUESTED_ROLLBACK_EXTENSION);
   }
@@ -343,7 +337,9 @@ public class FileCreateUtils extends FileCreateUtilsBase {
           if (writer.isEmpty()) {
             Files.createFile(metaFilePath);
           } else {
-            Files.write(metaFilePath, writer.map(FileCreateUtils::writeInstantContentToBytes).get());
+            try (OutputStream outputStream = Files.newOutputStream(metaFilePath)) {
+              writer.get().writeToStream(outputStream);
+            }
           }
         }
       } else {
@@ -361,7 +357,9 @@ public class FileCreateUtils extends FileCreateUtilsBase {
             if (writer.isEmpty()) {
               Files.createFile(metaFilePath);
             } else {
-              Files.write(metaFilePath, writer.map(FileCreateUtils::writeInstantContentToBytes).get());
+              try (OutputStream outputStream = Files.newOutputStream(metaFilePath)) {
+                writer.get().writeToStream(outputStream);
+              }
             }
           }
         }
@@ -590,15 +588,4 @@ public class FileCreateUtils extends FileCreateUtilsBase {
     deleteMetaFile(metaClient, instantTime, HoodieTimeline.INFLIGHT_SAVEPOINT_EXTENSION, storage);
     deleteMetaFile(metaClient, instantTime, HoodieTimeline.SAVEPOINT_EXTENSION, storage);
   }
-
-  @Deprecated
-  private static byte[] writeInstantContentToBytes(HoodieInstantWriter writer) {
-    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
-      writer.writeToStream(outputStream);
-      outputStream.flush();
-      return outputStream.toByteArray();
-    } catch (IOException ex) {
-      throw new HoodieIOException("Failed to convert to bytes", ex);
-    }
-  }
 }