Repository navigation
HLL: reject HLL8 register values above 63 - #814
Open
jaideeppyne wants to merge 1 commit into
Open
jaideeppyne wants to merge 1 commit into
jaideeppyne wants to merge 1 commit into
Conversation
Readers mask each slot with six bits, so a byte of 64 is read as an empty register and the estimate drops. Heapify and wrap now reject that image. Go and Rust already do.
This branch has not been deployed
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.
Problem
An HLL8 register is a rank in
0..63, stored in a byte.getSlotValuemasks withVAL_MASK_6, so a byte of 64 (bit 6 set) is read as 0, an empty slot. The distinct-count estimate then drops instead of the image being rejected.Go's
deserializeHll8and Rust'sHllSketch::deserializealready reject a rank above 63. Java heapify and wrap accepted it.Fix
Hll8Array.heapifyand bothDirectHll8Arrayconstructors scan the register bytes and throwSketchesArgumentExceptionwhen any value is above 63. Writers already store masked ranks, so sketches produced by this library are unchanged.Tests
mvn -Dtest=HllCorruptImageTest testwith JDK 25. 13 tests, 0 failures. The new case sets the last register of an HLL-mode image to 64 and checks heapify, wrap, writableWrap, and union heapify. The existing valid-image cases still match.