danny0405 opened a new pull request, #19198: URL: https://github.com/apache/hudi/pull/19198
### Describe the issue this Pull Request addresses This closes: #19197 Hudi file-name decoding is currently spread across `FSUtils`, `HoodieBaseFile`, `HoodieLogFile`, and several read/write call sites using repeated regex matching and ad hoc string splitting. This makes the behavior harder to reason about, especially now that both inline log files and native log files have to be supported consistently. This PR centralizes Hudi-generated base/log file-name parsing into a dedicated parser and routes existing helpers through that single decoding path. It also tightens base-file parsing so base files without a file extension are rejected, matching the reader-side expectation that supported base files have a concrete format extension. This PR changes common helper APIs: file-id prefix parsing moves from `FSUtils.getFileIdPfxFromFileId` to `FileNameParser.getFileIdPfxFromFileId`, and inline log file name construction is made explicit via `FSUtils.makeInlineLogFileName`. There is no storage format change. ### Summary and Changelog File-name parsing for Hudi base files, inline log files, and native log files is now centralized in `FileNameParser`, with `FSUtils`, `HoodieBaseFile`, and `HoodieLogFile` delegating to the decoded parser result instead of duplicating regex logic. #### Working tree: Centralize Hudi file-name parsing - Added `FileNameParser` for decoding base file names, inline log file names, native log file names, CDC log files, and file-id prefixes. - Removed base/log/native regex ownership from `FSUtils` and routed filename detail helpers through `FileNameParser`. - Removed fallback parsing for extensionless base files; `HoodieBaseFile` now throws `InvalidHoodiePathException` for unsupported Hudi-generated base file names without an extension. - Updated `HoodieLogFile` to decode log metadata through `FileNameParser`, including native-log detection and CDC detection. - Renamed inline log file construction to `FSUtils.makeInlineLogFileName` to distinguish it from native log file naming. - Moved `getFileIdPfxFromFileId` usage to `FileNameParser` in `ConsistentBucketIndexUtils` and `RDDSimpleBucketBulkInsertPartitioner`. - Reduced repeated file-name parsing in Spark/Flink reader contexts, CDC split construction, and log-reader summary logging. - Updated tests and fixtures to use supported base file names with extensions and the explicit inline log file-name helper. - Added parser coverage in `TestFSUtils` for base files, inline log files, native log files, CDC suffix handling, and file-id prefix validation. - Added `TestHoodieBaseFile` coverage for rejecting base files without extensions. ### Impact This affects common file-name parsing paths used by file-system views, base/log file models, Spark/Flink reader contexts, CDC utilities, and bucket-index helpers. There is no table format or storage layout change. Existing valid Hudi base files and log files should continue to parse the same way. Invalid extensionless base file names are now rejected instead of being partially decoded. Public helper API impact: - `FSUtils.getFileIdPfxFromFileId` is removed in favor of `FileNameParser.getFileIdPfxFromFileId`. - Inline log file construction is now named `FSUtils.makeInlineLogFileName`. ### Risk Level medium The risk is medium because this touches core filename parsing helpers used across read paths, write paths, file-system views, and tests. The risk is mitigated by centralizing behavior in one parser, preserving existing decoded field semantics, and adding focused parser and model tests. Validated with: - `git diff --check` - `mvn -pl hudi-hadoop-common -am -DskipITs -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -Dtest=TestFSUtils test` - `mvn -pl hudi-hadoop-common -am -DskipITs -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -Dtest=TestHoodieLogFile,TestFSUtils,TestHoodieLogFormatWriterBuilder test` ### Documentation Update none This is a common-code refactor and helper API cleanup with inline Javadocs added to `FileNameParser`. No user-facing configuration, table service behavior, or storage format documentation is required. ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] Adequate tests were added if applicable -- 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]
