cshuo commented on code in PR #19198:
URL: https://github.com/apache/hudi/pull/19198#discussion_r3528965858


##########
hudi-common/src/main/java/org/apache/hudi/common/fs/FSUtils.java:
##########
@@ -519,54 +452,31 @@ public static boolean isLogFile(StoragePath logPath) {
   }
 
   public static boolean isLogFile(String fileName) {
-    if (matchNativeLogFile(fileName).isPresent()) {
-      return true;
-    }
-    if (fileName.startsWith(LOG_FILE_START_WITH_CHARACTER)) {
-      Matcher matcher = LOG_FILE_PATTERN.matcher(fileName);
-      return matcher.matches() && matcher.group(3).equals(LOG_FILE_EXTENSION);
-    }
-    return false;
+    return FileNameParser.parseLogFile(fileName)
+        .map(logFileName -> logFileName.isNativeLogFile()
+            || 
logFileName.getFileExtension().equals(LogExtensions.DATA_LOG_EXTENSION))
+        .orElse(false);
   }
 
   public static boolean isInlineLogFile(String fileName) {
-    return matchNativeLogFile(fileName).isEmpty();
+    return FileNameParser.parseNativeLogFile(fileName).isEmpty();
   }
 
   public static Option<Matcher> matchNativeLogFile(String fileName) {
-    if (StringUtils.isNullOrEmpty(fileName)) {
-      return Option.empty();
-    }
-    String actualFileName = fileName.contains(StoragePath.SEPARATOR)
-        ? fileName.substring(fileName.lastIndexOf(StoragePath.SEPARATOR) + 1)
-        : fileName;
-    Matcher matcher = NATIVE_LOG_FILE_PATTERN.matcher(actualFileName);
-    return matcher.matches() ? Option.of(matcher) : Option.empty();
+    return FileNameParser.matchNativeLogFile(fileName);

Review Comment:
   Since the goal is to centralize name decoding, can we also migrate the 
remaining `Option<Matcher>` consumers to the typed API? 
`NativeLogFooterMetadata` still reads `group(8)`/`group(9)` and 
`TableSchemaResolver` passes the raw `Matcher` through, while 
`HoodieLogFormat`/`HoodieLogFormatReader`/`CdcIterators`/`CDCFileGroupIterator` 
only need an `isNativeLogFile` boolean. Keeping the `Matcher`-returning API 
public means a future regex/group-index change would break these callers 
silently.



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