danny0405 commented on code in PR #12926:
URL: https://github.com/apache/hudi/pull/12926#discussion_r1986198705


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/versioning/v2/ActiveTimelineV2.java:
##########
@@ -727,17 +725,15 @@ public void createFileInMetaPath(String filename, 
Option<byte[]> content, boolea
   protected void createCompleteFileInMetaPath(boolean shouldLock, 
HoodieInstant instant, Option<byte[]> content) {
     TimeGenerator timeGenerator = TimeGenerators
         .getTimeGenerator(metaClient.getTimeGeneratorConfig(), 
metaClient.getStorageConf());
-    timeGenerator.consumeTime(!shouldLock, currentTimeMillis -> {
-      String completionTime = HoodieInstantTimeGenerator.formatDate(new 
Date(currentTimeMillis));
-      String fileName = instantFileNameGenerator.getFileName(completionTime, 
instant);
-      StoragePath fullPath = getInstantFileNamePath(fileName);
-      if (metaClient.getTimelineLayoutVersion().isNullVersion()) {
-        FileIOUtils.createFileInPath(metaClient.getStorage(), fullPath, 
content);
-      } else {
-        metaClient.getStorage().createImmutableFileInPath(fullPath, 
content.map(HoodieInstantWriter::convertByteArrayToWriter));
-      }
-      LOG.info("Created new file for toInstant ?" + fullPath);
-    });
+    String completionTime = TimelineUtils.generateInstantTime(shouldLock, 
timeGenerator);

Review Comment:
   The lock scope can be narrowed, we only need to lock for time generation 
because the file creation is already atomic and the time is unique so there 
should be no conflicts.



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