Skip to content

feat(hfile): support ZSTD compression for metadata files - #20149

Open
linliu-code wants to merge 5 commits into
apache:masterfrom
linliu-code:delivery/mdt-zstd
Open

linliu-code wants to merge 5 commits into
apache:masterfrom
linliu-code:delivery/mdt-zstd

Conversation

@linliu-code

Copy link
Copy Markdown
Collaborator

Describe the issue this Pull Request addresses

Closes #14369; part of #14367. The native HFile compressor factory does not support ZSTD, and metadata writes do not inherit the main table's HFile compression setting.

This is a tested successor to Ethan's #14378. It depends on #19930: the branch currently includes that PR's three original commits, preserving their authorship. Keep this PR as a draft until #19930 lands, then rebase to remove the prerequisite commits from this diff. #14378 remains open for its author to retire when this successor is accepted.

Summary and Changelog

  • Register Ethan's Aircompressor ZSTD stream implementation in the native compressor factory, using bounded readFully for decompression.
  • Propagate hoodie.hfile.compression.algorithm into the metadata write configuration.
  • Calculate checksum length from the on-disk data size excluding checksum bytes, fixing exact checksum-chunk boundaries.
  • Cover heap/direct read-only buffers, empty and bounded decompression, embedded blocks with checksum boundaries, multi-block ZSTD scans, and MDT compression-setting propagation.
  • Preserve the existing 50 MB file-cache threshold; drop Add compressor implementation of zstd compression codec #14378's unrelated 1000 MB default change.

Impact

Users can opt into ZSTD for MDT HFile base files through hoodie.hfile.compression.algorithm=ZSTD. GZ remains the default. Existing NONE/GZ files remain readable. Deploy readers with ZSTD support before enabling ZSTD writes; older native readers do not support this codec.

Risk Level

medium. Adds an opt-in storage codec and propagates its setting into metadata writes.

Validation on JDK 11:

  • Full hudi-io suite: 138 tests passed, zero failures/errors/skips; Checkstyle and RAT passed.
  • TestHoodieMetadataWriteUtils with its reactor dependencies: 31 tests passed, zero failures/errors/skips; Checkstyle and RAT passed.
  • Manual cross-reader validation: native Hudi and HBase 2.4.13 each wrote a multi-block ZSTD HFile with 2,000 records; native full scans and HBase point lookups verified every key/value for both files. The local Hadoop 2 test classpath lacks Hadoop's ZSTD codec, so this check registered an independent zstd-jni 1.5.7-6 stream adapter with HBase. This validates the framing and HFile interoperability but does not exercise Hadoop's built-in JNI codec.

Documentation Update

The existing option and its GZ default are unchanged. The configuration description documents propagation to MDT and the native reader's supported codecs. A website configuration reference update should accompany release publication.

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

txwyy123 and others added 5 commits September 29, 2026 16:47
Exclude trailing checksum bytes from the native GZIP input stream and add a regression test for Hudi issue apache#19929.
Adapt the ZSTD codec from apache#14378 on top of the bounded decompression fix in apache#19930. Preserve the existing file-cache default and cover buffer, checksum, multi-block scan, and metadata configuration boundaries.

Co-authored-by: Y Ethan Guo <ethan.guoyihua@gmail.com>
@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Sep 30, 2026
@codecov-commenter

codecov-commenter commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.90%. Comparing base (602cc3d) to head (8312c8f).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20149      +/-   ##
============================================
- Coverage     80.42%   79.90%   -0.53%     
+ Complexity    34900    34649     -251     
============================================
  Files          2546     2547       +1     
  Lines        142929   142944      +15     
  Branches      17381    17381              
============================================
- Hits         114948   114215     -733     
- Misses        20064    20726     +662     
- Partials       7917     8003      +86     
Components Coverage Δ
hudi-common 83.64% <100.00%> (-0.33%) ⬇️
hudi-client 82.50% <100.00%> (-0.98%) ⬇️
hudi-flink 85.74% <ø> (-0.01%) ⬇️
hudi-spark-datasource 73.29% <ø> (-0.56%) ⬇️
hudi-utilities 78.18% <ø> (-0.01%) ⬇️
hudi-cli 70.05% <ø> (ø)
hudi-hadoop 69.54% <ø> (-1.44%) ⬇️
hudi-sync 76.02% <ø> (ø)
hudi-io 81.52% <100.00%> (+0.02%) ⬆️
hudi-timeline-service 78.42% <ø> (-4.65%) ⬇️
hudi-cloud 81.00% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (-0.77%) ⬇️
Flag Coverage Δ
common-and-other-modules 52.35% <100.00%> (+<0.01%) ⬆️
flink-integration-tests 49.46% <35.29%> (-0.01%) ⬇️
hadoop-mr-java-client 43.97% <35.29%> (-0.01%) ⬇️
integration-tests 13.45% <35.29%> (+<0.01%) ⬆️
spark-client-hadoop-common 38.58% <35.29%> (+<0.01%) ⬆️
spark-java-tests 48.92% <35.29%> (-3.48%) ⬇️
spark-scala-tests 47.08% <35.29%> (+0.02%) ⬆️
utilities 36.85% <35.29%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...apache/hudi/metadata/HoodieMetadataWriteUtils.java 93.35% <100.00%> (-1.09%) ⬇️
...apache/hudi/common/config/HoodieStorageConfig.java 91.03% <100.00%> (+0.54%) ⬆️
...ache/hudi/io/compress/HoodieCompressorFactory.java 100.00% <100.00%> (ø)
.../compress/airlift/HoodieAirliftZstdCompressor.java 100.00% <100.00%> (ø)
...main/java/org/apache/hudi/io/hfile/HFileBlock.java 94.23% <100.00%> (+0.17%) ⬆️

... and 146 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@linliu-code
linliu-code marked this pull request as ready for review September 30, 2026 13:31

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This slice of the stack only updates the documentation for hoodie.hfile.compression.algorithm. The new text says the setting also applies to metadata table HFiles and that the native HFile reader supports NONE, GZ and ZSTD. That matches what this PR introduces: ZSTD in the native compressor factory, and the setting now carried into the metadata write config. No issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review.

cc @yihua

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compressor implementation of ZSTD compression codec

7 participants