Repository navigation
Document that StreamingXXHash32.asChecksum() returns only 28 bits - #140
Merged
Merged
Conversation
yawkat
enabled auto-merge (squash)
September 25, 2026 15:46
The Checksum view masks the hash to its low 28 bits, which is part of the LZ4Block wire format. Document this on asChecksum() and in the LZ4BlockOutputStream format description, and add tests pinning the behaviour. No behaviour change. Fixes #115 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yawkat
force-pushed
the
fix/issue-115
branch
from
September 25, 2026 15:51
d8fca49 to
fbf3207
Compare
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.
Fixes #115.
This PR documents the existing 28-bit mask and does not change behaviour. Changing the mask would break the
LZ4BlockOutputStreamwire format.StreamingXXHash32.asChecksum(): the Javadoc now says thatgetValue()returnsgetValue() & 0x0FFFFFFFfor LZ4Block format compatibility, and points toStreamingXXHash32.getValue()for the full hash. The literal is also written as0x0FFFFFFFL; it is the same value.LZ4BlockOutputStream: the class Javadoc and the header comment describe the block header layout. They also say that the default checksum is the XXHash32 (seed0x9747b28c) of the uncompressed block, masked to 28 bits.Tests:
XXHash32Test.testAsChecksumIsMaskedTo28Bits: for all streaming implementations,asChecksum().getValue() == getValue() & 0x0FFFFFFF.LZ4BlockStreamingTest.testDefaultChecksumIsMaskedTo28Bits: pins the on-wire checksum bytes of a default block stream.🤖 Generated with Claude Code