boneanxs commented on code in PR #7627:
URL: https://github.com/apache/hudi/pull/7627#discussion_r1107973837


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieInstant.java:
##########
@@ -46,14 +55,35 @@ public class HoodieInstant implements Serializable, 
Comparable<HoodieInstant> {
   public static final Comparator<HoodieInstant> COMPARATOR = 
Comparator.comparing(HoodieInstant::getTimestamp)
       .thenComparing(ACTION_COMPARATOR).thenComparing(HoodieInstant::getState);
 
+  public static final Comparator<HoodieInstant> STATE_TRANSITION_COMPARATOR =
+      Comparator.comparing(HoodieInstant::getStateTransitionTime)
+          .thenComparing(HoodieInstant::getTimestamp)
+          
.thenComparing(ACTION_COMPARATOR).thenComparing(HoodieInstant::getState);
+
   public static String getComparableAction(String action) {
     return COMPARABLE_ACTIONS.getOrDefault(action, action);
   }
 
+  public static String extractTimestamp(String fileName) throws 
IllegalArgumentException {
+    Objects.requireNonNull(fileName);
+
+    Matcher matcher = NAME_FORMAT.matcher(fileName);
+    if (matcher.find()) {
+      return matcher.group(1);
+    }
+
+    throw new IllegalArgumentException(String.format(FILE_NAME_FORMAT_ERROR, 
fileName));
+  }
+
   public static String getTimelineFileExtension(String fileName) {
     Objects.requireNonNull(fileName);
-    int dotIndex = fileName.indexOf('.');
-    return dotIndex == -1 ? "" : fileName.substring(dotIndex);
+
+    Matcher matcher = NAME_FORMAT.matcher(fileName);

Review Comment:
   Here I just want to make all extraction logic follow the `NAME_FORMAT`, sry 
I didn't thought too much about the performance at the first time. Looks it 
could take more time than before.
   
   I run this method 1000 times, it will take 7-10 ms with the new codes, while 
for the old it takes 5 ms
   



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