Repository navigation
HLL: harden checks of coupon hash set images; document stringArrHash - #799
Merged
Merged
Conversation
The Array of Strings tuple sketch uses this hash as its key, so other languages need its exact definition: elements joined with "," without escaping, a null element as "null", the joined string hashed as UTF-16LE code units with no byte-order mark, XXH64 with seed 0x7A3CCA71. Adds a test that checks the method against that definition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
checkPreamble(), which heapify, wrap, writableWrap and HllUnion.heapify all call, now also checks a SET image against the limits a valid sketch keeps: - set mode requires lgK of at least 8; - a compact image holds at most 3/4 of 2^(lgK - 3) coupons, and the segment holds them; - in an updatable image lgArr, after the existing recompute for early images, is in [LG_INIT_SET_SIZE, lgK - 3], the table is at most 3/4 full, the segment holds the table, and the count equals the number of non-empty slots. The sanity checks inside DirectCouponList's promotions skip these limits, because there the sketch's own list or set is one coupon past its limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
proost
approved these changes
Nov 12, 2026
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.
This hardens the checks of HLL coupon hash set (SET mode) images, in line with apache/datasketches-cpp#565. It also documents the key hash of the Array of Strings tuple sketch.
HLL SET image checks
HllUtil.checkPreamble(), whichheapify,wrap,writableWrapandHllUnion.heapifyall call, now also checks a SET image against the limits a valid sketch keeps:lgArr(after the existing recompute for early images) is in [LG_INIT_SET_SIZE, lgK−3];Valid writers never produce images outside these limits. The sanity checks inside
DirectCouponList's promotions skip them, because there the sketch's own list or set is one coupon past its limit for a moment.Util.stringArrHashjavadocThis is the key hash of the Array of Strings tuple sketch, so other languages need its exact definition:
0x7A3CCA71.Tests
HllCorruptImageTestgets six new tests: compact count above the limit, a truncated compact image, updatablelgArrout of range, count not matching the table, an overfull table, and set mode with lgK 7. Each one fails if the new check is removed.StringArrHashTestchecksstringArrHashagainst the documented definition.The full suite passes (2,394 tests), and so do the C++, Go and Rust HLL deserialization checks against the local CL files.
🤖 Generated with Claude Code