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


##########
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:
   Consider this case:
   ```
                        String completionTime = "1000"                    file 
creation
   thread 1             |                                                       
             |
   thread 2                        |                                           |
                            String completionTime = "1002"    file creation
   ```
   This can let the file with smaller completion time written later in time.  
Should this be avoided?



##########
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:
   Consider this case:
   ```
                        String completionTime = "1000"                    file 
creation
   thread 1             |                                                       
  |
   thread 2                        |                                   |
                            String completionTime = "1002"    file creation
   ```
   This can let the file with smaller completion time written later in time.  
Should this be avoided?



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