feat: findDecompressedSize + frameHeaderSize, dedup content-size checks#30
Merged
Conversation
… checks
Adds two frame-inspection readers on ZstdFrame:
- decompressedSize(byte[]/MemorySegment) — exact combined decompressed size of
all concatenated frames, summed from each header (throws if any frame omits
its size). Complements decompressedBound (upper bound). Binds
ZSTD_findDecompressedSize.
- headerSize(byte[]/MemorySegment) — size of a frame header computed from just
its leading bytes (as few as 5), without a full parse. Binds
ZSTD_frameHeaderSize.
Extracts Zstd.requireStoredContentSize(long) for the CONTENTSIZE_UNKNOWN /
CONTENTSIZE_ERROR sentinel handling that was copy-pasted across three call
sites, and unifies the drifted error message ("not valid zstd data" vs "not a
valid zstd frame") to one.
ZSTD_getDecompressedSize intentionally not bound: deprecated, and blends
empty/unknown/error into 0 — the ambiguity ZSTD_getFrameContentSize (already
bound as Zstd.decompressedSize) was added to fix.
docs/supported.md: frame inspection 10 -> 12/13. CHANGELOG updated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two more frame-inspection readers on
ZstdFrame, plus a small refactor:ZstdFrame.decompressedSize(byte[] / MemorySegment)— exact combined decompressed size of all concatenated frames, summed from each header. Throws if any frame omits its size. ComplementsdecompressedBound(upper bound). BindsZSTD_findDecompressedSize.ZstdFrame.headerSize(byte[] / MemorySegment)— size of a frame header from just its leading bytes (as few as 5), without a full parse. BindsZSTD_frameHeaderSize.Zstd.requireStoredContentSize(long)— extracted theCONTENTSIZE_UNKNOWN/CONTENTSIZE_ERRORsentinel handling that was copy-pasted across 3 call sites, and unified the drifted error message ("not valid zstd data"vs"not a valid zstd frame").Not bound:
ZSTD_getDecompressedSizeDeprecated, and blends empty/unknown/error into
0— the exact ambiguityZSTD_getFrameContentSize(already bound asZstd.decompressedSize) was added to fix. Binding a strictly-worse deprecated call adds nothing.Tests
New
ZstdFrameTest.DecompressedSize(single frame, concatenated sum, segment parity, unknown-size frame throws, garbage) andZstdFrameTest.HeaderSize(matches parsed header, computed from 5-byte prefix, segment parity, too-short rejected). 221 unit + 81 integration green, javadoc + checkstyle clean.Notes
docs/supported.md: frame inspection 10 → 12/13.CHANGELOG.mdUnreleased updated.🤖 Generated with Claude Code