You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "danny0405 (via GitHub)" <gi...@apache.org> on 2026/07/15 04:08:21 UTC
[PR] fix: fix the file size calibration for native log format [hudi]
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "cshuo (via GitHub)" <gi...@apache.org>.
cshuo commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592588188
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
Review Comment:
Should we retain the `PARQUET_DATA_BLOCK` guard here? `hoodie.logfile.data.block.format=parquet` is still supported for legacy v9 tables, where applying the configured fraction recalibrates physical Parquet log sizes and affects both average record-size estimation and bucket sizing. The previous regression test covered this case as well.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592612243
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
This is intential, native log format is the substitute for inline log with native format now.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
}
- return config.getLogFileToParquetCompressionRatio();
+ return 1D;
Review Comment:
the method is used for avg record size estimation, it is kind of redundant for getTotalFileSize.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous merged PR #19293:
URL: https://github.com/apache/hudi/pull/19293
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3584477225
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,42 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ boolean isAvroDataBlocks = HoodieLogBlockType.fromId(writeConfig.getStringOrDefault(
Review Comment:
🤖 Here `isAvroDataBlocks` is derived purely from `LOGFILE_DATA_BLOCK_FORMAT` (defaulting to `avro`), but `DeltaWriteProfile.logFileToParquetCompressionRatio` resolves the effective type via `CommonClientUtils.getLogBlockType`, which also falls back to the base-file format when that config is unset. For a table with the config unset but a non-Avro effective block type (e.g. HFILE base format), this path would still calibrate the inline logs while the Flink avg-size path would not. Is that divergence intentional? (I realize hudi-common can't reach `getLogBlockType` directly, so this may just be an accepted tradeoff worth a comment.)
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +125,10 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
Review Comment:
🤖 nit: it looks like `logFileToParquetCompressionRatio()` is no longer called after `getTotalFileSize` was updated to delegate to `fileSlice.getTotalFileSizeAsParquetFormat(config)` directly — could this private method be removed? Leaving it around risks confusing a future reader about whether it represents the authoritative calibration logic or is just a stale copy.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592627032
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
Review Comment:
drop it intentionally and don't want to bring up to much complesities here. Almost no one uses parquet inline log in practice.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592884218
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
Review Comment:
🤖 nit: these two stream pipelines are identical except for the native-vs-inline filter — could you extract a small helper like `sumLogFileSizes(Predicate<HoodieLogFile>)` to avoid the duplication?
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ // The effective inline block type cannot be inferred from the log file name, and hudi-common does not have access
+ // to the table config fallback used by write clients. Legacy callers with no explicit block format default to Avro.
+ boolean isAvroDataBlocks = HoodieLogBlockType.fromId(writeConfig.getStringOrDefault(
Review Comment:
🤖 nit: `isAvroDataBlocks` is a boolean, so the singular `isAvroDataBlock` reads a bit better as a predicate.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3594130064
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ // The effective inline block type cannot be inferred from the log file name, and hudi-common does not have access
+ // to the table config fallback used by write clients. Legacy callers with no explicit block format default to Avro.
+ boolean isAvroDataBlocks = HoodieLogBlockType.fromId(writeConfig.getStringOrDefault(
Review Comment:
just let it throw if the name does not match.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592766421
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
}
- return config.getLogFileToParquetCompressionRatio();
+ return 1D;
Review Comment:
I aligned the per-file Spark and Flink paths: all callers now pass the write config to `FileSlice`, which applies the ratio only to inline Avro logs and uses physical size for native and inline non-Avro logs. There is no table-version gate in that per-file path, so upgraded slices with legacy inline Avro logs behave consistently. The version gate remains only for delta commit metadata because it does not identify log-file formats individually.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +125,10 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
Review Comment:
This method is still used by `averageBytesPerRecord()` when calling `calculateRecordSizeThroughCommitMetadata(deltaCommitTimeline, logFileToParquetCompressionRatio())`. The config-based `FileSlice` path is authoritative for per-file sizing, while this helper is retained only for delta commit metadata, which cannot distinguish inline from native log files. I added a comment to make that distinction explicit.
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,42 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ boolean isAvroDataBlocks = HoodieLogBlockType.fromId(writeConfig.getStringOrDefault(
Review Comment:
Yes, this is an accepted limitation of the common-model path. `FileSlice` cannot consult the table-config fallback, so the restored config-based API reads the explicitly supplied inline block format and preserves Avro as the legacy default when it is unset. I added a comment documenting that assumption. Native log files are still identified from their file names and always use their physical size.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
I added a comment documenting that the commit-metadata version gate assumes the write version has been reconciled with the table version. The per-file `FileSlice` path intentionally has no version gate: it distinguishes native and inline files directly, so legacy inline Avro logs in an upgraded v10 slice are still calibrated. The version gate now applies only to delta commit metadata, where that per-file distinction is unavailable.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
Review Comment:
Yes. I restored the effective block-type guard in `logFileToParquetCompressionRatio()` using `CommonClientUtils.getLogBlockType(...)`, so the ratio is returned only for pre-v10 Avro log blocks. I also restored `testDeltaWriteProfileRecordsPerBucketSkipsCompressionRatioForParquetLogBlocks` to cover the v9 Parquet case.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
Good catch. I restored the write config parameter on `FileSlice.getTotalFileSizeAsParquetFormat` so it can inspect the configured inline block format. It now calibrates only inline Avro logs; inline Parquet/HFile and native logs use their physical size. I also restored `testDeltaWriteProfileRecordsPerBucketSkipsCompressionRatioForParquetLogBlocks` and added FileSlice coverage for Avro, Parquet, and HFile.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3593195104
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ // The effective inline block type cannot be inferred from the log file name, and hudi-common does not have access
+ // to the table config fallback used by write clients. Legacy callers with no explicit block format default to Avro.
+ boolean isAvroDataBlocks = HoodieLogBlockType.fromId(writeConfig.getStringOrDefault(
Review Comment:
`fromId` is a plain map lookup, so a user who sets `AVRO` gets null here and silently skips calibration. Worth lowercasing the configured value before the lookup?
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ // The effective inline block type cannot be inferred from the log file name, and hudi-common does not have access
+ // to the table config fallback used by write clients. Legacy callers with no explicit block format default to Avro.
Review Comment:
The `avro` fallback diverges from `CommonClientUtils.getLogBlockType`, which infers the block type from the base format when unset (HFILE base -> HFILE blocks). None of the current callers pass MDT slices so this is latent, but since `FileSlice` carries its base file we could infer from the base file extension when one is present, or at least call out the parquet-base-table assumption in the javadoc.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestPartitionDirectoryConverter.scala:
##########
@@ -49,6 +51,7 @@ class TestPartitionDirectoryConverter extends SparkAdapterSupport {
val options = Map(
s"${HoodieStorageConfig.LOGFILE_TO_PARQUET_COMPRESSION_RATIO_FRACTION.key()}" -> logFraction.toString
)
+ val config = new HoodieConfig(TypedProperties.fromMap(options.asJava))
Review Comment:
Could we add one slice with a native log file here too? `TestFileSlice` covers the math, but this is the Spark split-sizing path that benefits from the fix.
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieFileIndex.scala:
##########
@@ -106,6 +106,9 @@ case class HoodieFileIndex(spark: SparkSession,
@transient protected var hasPushedDownPartitionPredicates: Boolean = false
+ private lazy val hoodieConfig =
Review Comment:
nit: the neighboring derived fields are `@transient`; probably worth marking this one too since it is derivable from `options`.
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
Review Comment:
Since this is public API in hudi-common, keeping a `@Deprecated` overload taking the old `double` (delegating with a synthetic config) would give external callers a release to migrate. The description already flags the break; this would make it painless.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3594120302
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
+ long logFileSize = convertLogFilesSizeToExpectedParquetSize(writeConfig);
return getBaseFile().isPresent() ? getBaseFile().get().getFileSize() + logFileSize : logFileSize;
}
- private long convertLogFilesSizeToExpectedParquetSize(double logFileFraction) {
- long totalSizeOfLogFiles =
+ private long convertLogFilesSizeToExpectedParquetSize(HoodieConfig writeConfig) {
+ long totalSizeOfInlineLogFiles =
+ logFiles.stream()
+ .filter(logFile -> !logFile.isNativeLogFile())
+ .map(HoodieLogFile::getFileSize)
+ .filter(size -> size > 0)
+ .reduce(Long::sum)
+ .orElse(0L);
+ long totalSizeOfNativeLogFiles =
logFiles.stream()
+ .filter(HoodieLogFile::isNativeLogFile)
.map(HoodieLogFile::getFileSize)
.filter(size -> size > 0)
.reduce(Long::sum)
.orElse(0L);
- // Here we assume that if there is no base parquet file, all log files contain only inserts.
+ // Here we assume that if there is no base parquet file, all calibrated log files contain only inserts.
// We can then just get the parquet equivalent size of these log files, compare that with
// {@link config.getParquetMaxFileSize()} and decide if there is scope to insert more rows
- return (long) (totalSizeOfLogFiles * logFileFraction);
+ // The effective inline block type cannot be inferred from the log file name, and hudi-common does not have access
+ // to the table config fallback used by write clients. Legacy callers with no explicit block format default to Avro.
Review Comment:
this is fine, since MDT is kind of fixed size bucket index, there is no small file group bin-packing.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592623629
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
}
- return config.getLogFileToParquetCompressionRatio();
+ return 1D;
Review Comment:
the method is used for avg record size estimation, it is kind of redundant for getTotalFileSize.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592612243
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
This is intential, native log format is the substitute for inline log with native format now.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3594135326
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
Review Comment:
this is not a developer API to external developers I think.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3594233951
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieFileIndex.scala:
##########
@@ -106,6 +106,9 @@ case class HoodieFileIndex(spark: SparkSession,
@transient protected var hasPushedDownPartitionPredicates: Boolean = false
+ private lazy val hoodieConfig =
Review Comment:
Done in `ee04a6508a38`. I marked the derived `hoodieConfig` as `@transient private lazy val`, consistent with the neighboring driver-side derived state.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/TestPartitionDirectoryConverter.scala:
##########
@@ -49,6 +51,7 @@ class TestPartitionDirectoryConverter extends SparkAdapterSupport {
val options = Map(
s"${HoodieStorageConfig.LOGFILE_TO_PARQUET_COMPRESSION_RATIO_FRACTION.key()}" -> logFraction.toString
)
+ val config = new HoodieConfig(TypedProperties.fromMap(options.asJava))
Review Comment:
Added a dedicated `testConvertNativeLogFileSliceToPartitionDirectory` in `ee04a6508a38`. It constructs a native `.log.parquet` slice, verifies it is recognized as native, and asserts the Spark delegate file keeps the native log physical size instead of applying the inline-log fraction. All 7 `TestPartitionDirectoryConverter` tests pass.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19293:
URL: https://github.com/apache/hudi/pull/19293#issuecomment-4976787702
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "c532c769606ed7777a7f0f970656d9c5f618bc5c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "c532c769606ed7777a7f0f970656d9c5f618bc5c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* c532c769606ed7777a7f0f970656d9c5f618bc5c UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592543689
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
One caveat on the gate: `getWriteVersion()` reads `hoodie.write.table.version`, which defaults to `current()` (=10). Normally that's reconciled to the on-disk version, but mid-upgrade (v9 -> v10) or with a misconfigured writer a slice can still hold legacy inline Avro logs while this reports `10` -- and we'd skip calibration for row-based logs that genuinely need it. Might be worth a comment noting this assumes a reconciled write version.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
}
- return config.getLogFileToParquetCompressionRatio();
+ return 1D;
Review Comment:
Worth flagging that Spark and Flink diverge after this change. The Spark callers (`SparkUpsertDeltaCommitPartitioner`, `PartitionDirectoryConverter`) pass `getLogFileToParquetCompressionRatio()` with no version gate, so on an upgraded v10 slice that still has inline Avro logs Spark calibrates them and Flink (forced to `1D`) doesn't.
Since `FileSlice` already routes native -> physical / inline -> ratio per file, this gate is mostly redundant for the `getTotalFileSize` path -- it only really matters for `calculateRecordSizeThroughCommitMetadata`, which isn't per-file. Could we align the two engines, or drop a note on why they differ?
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
Review Comment:
This version gate quietly reverts the `PARQUET_DATA_BLOCK` skip added in #18991. On a v9 table with `hoodie.logfile.data.block.format=parquet` (or `hfile`) the log files are still inline (`isNativeLogFile() == false`), so we hand back the ratio and re-calibrate blocks whose physical size is already parquet-sized -- the exact over-calibration #18991 fixed. The removed `testDeltaWriteProfileRecordsPerBucketSkipsCompressionRatioForParquetLogBlocks` was guarding this.
If dropping v9 + non-Avro inline blocks is intentional (native logs being the way forward), can we call that out in the PR description? If not, the inline branch needs to look at the configured block format too, not just the version -- `FileSlice` can't tell Avro from parquet inline blocks on its own, since the format isn't in the file name.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3601468087
##########
hudi-common/src/main/java/org/apache/hudi/common/model/FileSlice.java:
##########
@@ -193,24 +196,44 @@ public boolean isEmpty() {
}
/**
- * Get the total file size of a file slice similar on the base file.
- * For the log file, we need to convert its size to the estimated size similar on the base file in a certain proportion
+ * Gets the estimated total size of a file slice in the base Parquet format.
+ *
+ * <p>Only inline Avro log files need size calibration. Native log files and inline non-Avro log files
+ * use their physical sizes directly.</p>
+ *
+ * @param writeConfig write config containing the log data block format and log-to-Parquet compression ratio
*/
- public long getTotalFileSizeAsParquetFormat(double logFileFraction) {
- long logFileSize = convertLogFilesSizeToExpectedParquetSize(logFileFraction);
+ public long getTotalFileSizeAsParquetFormat(HoodieConfig writeConfig) {
Review Comment:
It may not be, it's for hygiene. Given that it's in hudi-common, we ought to be careful. Nonetheless, feel free to ignore this for now.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: fix the file size calibration for native log format [hudi]
Posted by "danny0405 (via GitHub)" <gi...@apache.org>.
danny0405 commented on code in PR #19293:
URL: https://github.com/apache/hudi/pull/19293#discussion_r3592627032
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/partitioner/profile/DeltaWriteProfile.java:
##########
@@ -123,10 +123,9 @@ private boolean isSmallFile(FileSlice fileSlice) {
}
private double logFileToParquetCompressionRatio() {
- if (config.getLogDataBlockFormat().isPresent()
- && config.getLogDataBlockFormat().get() == HoodieLogBlock.HoodieLogBlockType.PARQUET_DATA_BLOCK) {
- return 1D;
+ if (config.getWriteVersion().lesserThan(HoodieTableVersion.TEN)) {
+ return config.getLogFileToParquetCompressionRatio();
Review Comment:
drop it intentionally and don't want to bring up to much complesities here. Almost no one uses parquet inline log in practice.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org