feat(storage): support separate zstd level for native parquet logs - #19781
feat(storage): support separate zstd level for native parquet logs#19781cshuo wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19781 +/- ##
============================================
+ Coverage 78.11% 78.15% +0.03%
- Complexity 33673 33695 +22
============================================
Files 2540 2540
Lines 141413 141441 +28
Branches 17123 17126 +3
============================================
+ Hits 110467 110545 +78
+ Misses 23250 23200 -50
Partials 7696 7696
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
hudi-agent
left a comment
There was a problem hiding this comment.
Thanks for working on this! This PR adds a hoodie.logfile.parquet.compression.codec.zstd.level config (default 1) and a ParquetUtils helper that applies it only to native Parquet log paths, wired into the Spark/Flink/Avro writer factories ahead of the custom injector. The mechanics look correct — newInstance() deep-copies so base-file configs aren't mutated, and native-vs-base path detection is right. One thing worth double-checking is the backward-compat implication of the default value, noted inline. Please take a look at any inline comments, and this should be ready for a Hudi committer or PMC member to take it from here. One naming nit worth addressing; code is otherwise clean and well-structured.
|
|
||
| public static final ConfigProperty<String> LOGFILE_PARQUET_COMPRESSION_CODEC_ZSTD_LEVEL = ConfigProperty | ||
| .key("hoodie.logfile.parquet.compression.codec.zstd.level") | ||
| .defaultValue("1") |
There was a problem hiding this comment.
🤖 Since this defaults to 1 and applyNativeLogZstdCompressionLevel applies it whenever it differs from the global setting, existing tables using zstd for native log files will silently drop to level 1 on upgrade (from their configured global parquet.compression.codec.zstd.level, or parquet's default of 3 if unset). Is that intended for existing users, or should the override only kick in when this config is explicitly set and otherwise inherit the global level? Might be worth calling out as a behavior change either way.
| * so base file writers and other users of the shared configuration are not affected. | ||
| */ | ||
| public static <T> StorageConfiguration<T> applyNativeLogZstdCompressionLevel( | ||
| StoragePath path, StorageConfiguration<T> storageConf, HoodieConfig hoodieConfig) { |
There was a problem hiding this comment.
🤖 This applies the zstd level to every native log write regardless of the actual log compression codec (default is gzip). When the codec isn't zstd, setting parquet.compression.codec.zstd.level is a no-op but still forces a full Configuration deep-copy per log-writer creation. Since hoodieConfig already carries PARQUET_COMPRESSION_CODEC_NAME, would it make sense to gate this on the codec actually being zstd?
|
|
||
| @Test | ||
| void testApplyNativeLogZstdCompressionLevel() { | ||
| String parquetZstdLevel = "parquet.compression.codec.zstd.level"; |
There was a problem hiding this comment.
🤖 nit: this string literal duplicates the private PARQUET_COMPRESSION_CODEC_ZSTD_LEVEL constant in ParquetUtils. If the constant changes, the test would silently pass against the wrong key. Could you either make the constant package-private (or @VisibleForTesting) so the test can reference it directly, or at least add a comment tying it back to the source constant?
Describe the issue this Pull Request addresses
Closes #19780.
The global Hadoop
parquet.compression.codec.zstd.levelsetting currently applies to both Parquet base files and native Parquet log files. Native logs favor write latency and may not need the higher compression level selected for base files, but there is no independent native-log setting.Summary and Changelog
hoodie.logfile.parquet.compression.codec.zstd.levelconfiguration with a default value of1.ParquetUtilshelper that applies the native-log level only to native log paths, copying the storage configuration only when the global level is absent or different.HoodieParquetConfigInjectorin Spark, Flink, and Avro/Java Parquet writer factories, preserving the custom injector as the highest-priority extension point.Impact
Users can tune native Parquet log Zstd compression independently from base files. Native logs default to level
1, while base files retain the global Hadoop setting. This adds one optional advanced configuration and does not change Hudi's storage format or public APIs.Risk Level
Low. The override is limited to native log paths, base-file paths retain the original configuration instance, and custom Parquet config injectors still run last. The targeted
TestParquetUtils#testApplyNativeLogZstdCompressionLeveland Flink Parquet writer factory test passed.Documentation Update
The new configuration and its default behavior are documented in
HoodieStorageConfig. No storage-format documentation changes are required.Contributor's checklist