refactor: finish value-object migration for API stabilization#102
Merged
Conversation
…iant Stabilizes the public API by removing the remaining primitive-obsession stragglers, so the value-object story is complete before the surface freezes. Sizes -> ZstdByteSize: - ZstdFrame.compressedSize / headerSize / decompressionMargin (were long) - ZstdDictionary.size() / headerSize() (were int) Now consistent with decompressedSize/decompressedBound/sizeOf(), which already returned ZstdByteSize. The zero-copy segment compress/decompress overloads deliberately keep their raw long return (the count feeds straight into MemorySegment.asSlice); documented as such. New value types: - ZstdWindowLog (windowLog / windowLogMax), validated against the linked libzstd's accepted range, with AUTO (0) for "library chooses". - ZstdMagicVariant (writeSkippableFrame / ZstdSkippableContent.magicVariant), validated to 0..15. Also documents the earlier, undocumented decompress(int -> ZstdByteSize) change and the new decompress(byte[]) overload in CHANGELOG [Unreleased], and migrates all callers (unit, integration, smoke) plus adds tests for the two new types. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Unifies Zstd.version() (was String "1.5.7") and Zstd.versionNumber() (was int 10507) into a single comparable ZstdVersion(major, minor, patch) value type: - number() gives the packed MAJOR*10000+MINOR*100+PATCH form - toString() gives the "x.y.z" string - isAtLeast(int, int, int) / Comparable enable feature-gating against the linked libzstd Zstd.version() now returns ZstdVersion and is decoded from ZSTD_versionNumber, so the ZSTD_versionString binding is dropped as dead. Migrates callers (unit, smoke), adds ZstdVersionTest, updates docs and CHANGELOG. 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.
Why
Preparing to stabilize the public API. Audited the whole surface for remaining primitive-obsession stragglers — cases where a public method still takes/returns a naked
int/long/Stringthat should be a value object, inconsistent with the 0.11ByteSize/CompressionLevelmigration. This closes those gaps so the surface is consistent before it freezes.Sizes →
ZstdByteSizeThese were the odd ones out — the same classes already returned
ZstdByteSizefrom their other size methods:ZstdFrame.compressedSize(byte[]/MemorySegment)longZstdByteSizeZstdFrame.headerSize(byte[]/MemorySegment)longZstdByteSizeZstdFrame.decompressionMargin(byte[]/MemorySegment)longZstdByteSizeZstdDictionary.size()/headerSize()intZstdByteSizeThe zero-copy segment
compress/decompressoverloads keep their rawlongreturn by design (the count feeds straight intoMemorySegment.asSlice, and boxing it would tax the fast path) — now documented on those methods.New value types
ZstdWindowLog— forZstdCompressContext.windowLog/ZstdDecompressContext.windowLogMax. Validates against the linked libzstd's accepted window-log range;ZstdWindowLog.AUTO(0) means "library chooses".ZstdMagicVariant— forZstdFrame.writeSkippableFrameandZstdSkippableContent.magicVariant(). Validates to0..15.ZstdVersion— replaces the splitString version()/int versionNumber()with one comparable(major, minor, patch):number()(packed form),toString()(x.y.z), andisAtLeast(int,int,int)for feature-gating. TheZSTD_versionStringbinding is dropped as dead (decoded fromZSTD_versionNumber).Also in this PR
[Unreleased]breaking changes surfaced during the audit:ZstdDecompressContext.decompress(byte[], int …)→ZstdByteSize(all three overloads), and the newdecompress(byte[])no-bound overload.Out of scope (noted for a later decision)
ZstdFrameHeaderis a raw parsed-struct record (windowSize/blockSizeMax/headerSizeare all nakedlong/int) — value-object-ifying the whole struct is a separate call.Testing
./mvnw clean testgreen (zstd 324 + new type tests); integration + validate + javadoc clean.🤖 Generated with Claude Code