vinothchandar commented on code in PR #9776:
URL: https://github.com/apache/hudi/pull/9776#discussion_r1342607441


##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java:
##########
@@ -101,12 +103,36 @@ public void addBaseFile(HoodieBaseFile dataFile) {
 
   /**
    * Add a new log file into the group.
+   *
+   * <p>CAUTION: the log file must be added in sequence of the delta commit 
time.

Review Comment:
   lets add a validation check for this?



##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFileCreationHook.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.common.table.log;
+
+import org.apache.hudi.common.model.HoodieLogFile;
+
+/**
+ * A hook allowing plug-in logic for log file creation.
+ */
+public interface HoodieLogFileCreationHook {

Review Comment:
   rename: LogFileCreationCallback ?



##########
hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java:
##########
@@ -544,15 +543,40 @@ public static Option<Pair<Integer, String>> 
getLatestLogVersion(FileSystem fs, P
   }
 
   /**
-   * computes the next log version for the specified fileId in the partition 
path.
+   * Get the latest log version for the fileId in the partition path.
+   */
+  public static int getLatestLogVersion(FileSystem fs, Path partitionPath, 
final String fileId,
+                                                        final String 
logFileExtension, final String deltaCommitTime, final String writeToken) throws 
IOException {
+    int version = HoodieLogFile.LOGFILE_BASE_VERSION;
+    String logFileName = makeLogFileName(fileId, logFileExtension, 
deltaCommitTime, version, writeToken);
+    while (fileExists(fs, new Path(partitionPath, logFileName))) {

Review Comment:
   would like to avoid these fs calls. Can't we have the log file versions be 
used locally generated by writers, since the delta commit time is anyway in the 
log file name to differentiate?



##########
hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java:
##########
@@ -544,15 +543,40 @@ public static Option<Pair<Integer, String>> 
getLatestLogVersion(FileSystem fs, P
   }
 
   /**
-   * computes the next log version for the specified fileId in the partition 
path.
+   * Get the latest log version for the fileId in the partition path.
+   */
+  public static int getLatestLogVersion(FileSystem fs, Path partitionPath, 
final String fileId,

Review Comment:
   fix formatting?
   



##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieFileGroup.java:
##########
@@ -101,12 +103,36 @@ public void addBaseFile(HoodieBaseFile dataFile) {
 
   /**
    * Add a new log file into the group.
+   *
+   * <p>CAUTION: the log file must be added in sequence of the delta commit 
time.
    */
-  public void addLogFile(HoodieLogFile logFile) {
-    if (!fileSlices.containsKey(logFile.getBaseCommitTime())) {
-      fileSlices.put(logFile.getBaseCommitTime(), new FileSlice(fileGroupId, 
logFile.getBaseCommitTime()));
+  public void addLogFile(CompletionTimeQueryView completionTimeQueryView, 
HoodieLogFile logFile) {
+    String baseInstantTime = getBaseInstantTime(completionTimeQueryView, 
logFile);
+    if (!fileSlices.containsKey(baseInstantTime)) {
+      fileSlices.put(baseInstantTime, new FileSlice(fileGroupId, 
baseInstantTime));
+    }
+    fileSlices.get(baseInstantTime).addLogFile(logFile);
+  }
+
+  private String getBaseInstantTime(CompletionTimeQueryView 
completionTimeQueryView, HoodieLogFile logFile) {

Review Comment:
   unit test these methods?



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