This is an automated email from the ASF dual-hosted git repository. yihua pushed a commit to branch branch-0.x in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 50f367dbe1fca428b404fe04a91d7593dac0b311 Author: Danny Chan <[email protected]> AuthorDate: Fri Apr 19 14:07:47 2024 +0800 [HUDI-7640] Uses UUID as temporary file suffix for HoodieStorage.createImmutableFileInPath (#11052) --- .../src/main/java/org/apache/hudi/storage/HoodieStorage.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hudi-io/src/main/java/org/apache/hudi/storage/HoodieStorage.java b/hudi-io/src/main/java/org/apache/hudi/storage/HoodieStorage.java index adf9371c243..be160caba3b 100644 --- a/hudi-io/src/main/java/org/apache/hudi/storage/HoodieStorage.java +++ b/hudi-io/src/main/java/org/apache/hudi/storage/HoodieStorage.java @@ -37,6 +37,7 @@ import java.io.OutputStream; import java.net.URI; import java.util.ArrayList; import java.util.List; +import java.util.UUID; /** * Provides I/O APIs on files and directories on storage. @@ -45,7 +46,6 @@ import java.util.List; @PublicAPIClass(maturity = ApiMaturityLevel.EVOLVING) public abstract class HoodieStorage implements Closeable { public static final Logger LOG = LoggerFactory.getLogger(HoodieStorage.class); - public static final String TMP_PATH_POSTFIX = ".tmp"; /** * @return the scheme of the storage. @@ -249,8 +249,11 @@ public abstract class HoodieStorage implements Closeable { * empty, will first write the content to a temp file if {needCreateTempFile} is * true, and then rename it back after the content is written. * - * @param path file path. - * @param content content to be stored. + * <p>CAUTION: if this method is invoked in multi-threads for concurrent write of the same file, + * an existence check of the file is recommended. + * + * @param path File path. + * @param content Content to be stored. */ @PublicAPIMethod(maturity = ApiMaturityLevel.EVOLVING) public final void createImmutableFileInPath(StoragePath path, @@ -267,7 +270,7 @@ public abstract class HoodieStorage implements Closeable { if (content.isPresent() && needTempFile) { StoragePath parent = path.getParent(); - tmpPath = new StoragePath(parent, path.getName() + TMP_PATH_POSTFIX); + tmpPath = new StoragePath(parent, path.getName() + "." + UUID.randomUUID()); fsout = create(tmpPath, false); fsout.write(content.get()); }
