danny0405 opened a new pull request, #19293:
URL: https://github.com/apache/hudi/pull/19293

   ### Describe the issue this Pull Request addresses
   
   `FileSlice.getTotalFileSizeAsParquetFormat` previously applied the 
configured log-to-Parquet compression ratio to every log file in a file slice. 
This incorrectly recalibrated native log files and inline log files containing 
non-Avro data blocks, even though their physical sizes already represent the 
expected size.
   
   `DeltaWriteProfile` also applied the compression ratio without accounting 
for the table version. Table version 10 uses native logs, so calibration should 
only apply to tables below version 10 when the effective inline data block type 
is Avro.
   
   ### Summary and Changelog
   
   This change limits log-to-Parquet size calibration to legacy inline Avro log 
files and preserves the physical size for native and non-Avro log files.
   
   #### Working tree: calibrate only inline Avro log files
   
   - Changed `FileSlice.getTotalFileSizeAsParquetFormat` to accept 
`HoodieConfig` instead of a compression-ratio scalar.
   - Separately sums inline and native log file sizes.
   - Applies the compression ratio once to the total inline log size when the 
configured data block format is Avro.
   - Uses physical sizes for native log files and inline Parquet/HFile data 
blocks.
   - Updated Spark and Flink callers, including 
`SparkUpsertDeltaCommitPartitioner`, `DeltaWriteProfile`, `HoodieFileIndex`, 
and `PartitionDirectoryConverter`.
   - Updated `DeltaWriteProfile.logFileToParquetCompressionRatio` to return the 
configured ratio only when the write table version is below 10 and the 
effective log data block type is Avro; all other cases return `1`.
   - Added `TestFileSlice` coverage for mixed inline/native logs and Avro, 
Parquet, and HFile block formats.
   - Added `TestBucketAssigner` coverage for version 9 inline logs and version 
10 native logs.
   - Updated `TestPartitionDirectoryConverter` for the configuration-based API.
   
   ### Impact
   
   This improves small-file detection, bucket sizing, average-record-size 
estimation, and Spark file-split estimation for Merge-On-Read tables using 
native or non-Avro log files.
   
   There are no storage-format, configuration-default, or runtime compatibility 
changes. The public `FileSlice.getTotalFileSizeAsParquetFormat` method 
signature changes from accepting a compression ratio to accepting 
`HoodieConfig`; all in-repository callers are updated, but direct downstream 
callers may require a source update.
   
   ### Risk Level
   
   medium
   
   The change affects shared file-slice size estimation used by Spark and Flink 
write/read paths. Risk is mitigated by targeted coverage and successful 
validation:
   
   - `TestFileSlice`: 7 tests passed.
   - `TestBucketAssigner`: 17 tests passed, including inline Avro, inline 
Parquet, and native-log scenarios.
   - The affected Flink dependency reactor completed successfully.
   - The affected Spark, Flink, and common modules compiled successfully.
   - `git diff --check` passed.
   
   ### Documentation Update
   
   none
   
   This corrects internal size-estimation behavior without introducing a new 
configuration, changing a default, or adding a user-facing feature.
   
   ### 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]

Reply via email to