Repository navigation
Conversation
…erge; KLL items merge compares min and max before committing REQ - merge() throws SketchesArgumentException, with the sketch unchanged, if the combined N would exceed Long.MAX_VALUE. - update() throws SketchesStateException, with the sketch unchanged, if N is already Long.MAX_VALUE. - merge() sets N, min and max after the compactors are merged. If that merge is interrupted, N is advanced by the weight actually merged, and min and max include the other sketch's only if items were merged. - Javadoc for both methods names the exceptions. KLL - The items merge computes the new min and max before it commits N, the levels and the items, so a comparator that throws there leaves the sketch as it was after the level-0 updates. The doubles, floats and longs merges were checked and need no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Java counterparts of issues found while reviewing ds-cpp #587. Independent of #808 (no conflict): #808 covers
update()andcompress(), this PR covers the N limit andmerge().REQ
No limit on N.
update()didtotalN++andmerge()didtotalN += other.totalNwith no check, so repeated merges could wrap N negative. KLL already usesMath.addExact; C++ now caps N at 2^63-1.merge()throwsSketchesArgumentExceptionif the combined N would exceedLong.MAX_VALUE. The sketch is unchanged.update()throwsSketchesStateExceptionif N is alreadyLong.MAX_VALUE. The sketch is unchanged. NaN updates are still ignored.A failed merge left N out of step.
merge()added the other sketch's N and set min and max before merging the compactors. If that failed partway, N counted items that were never merged.Both methods' javadoc now names the exceptions.
KLL
I checked the four KLL merge implementations for failures partway through.
MemorySegmentRequest, have succeeded.Testing
ReqMergeLimitsTest:mergeRejectsNAboveMaxandupdateRejectsNAboveMax: the sketch image is unchanged after the exception, and a merge can reach exactlyLong.MAX_VALUE.partialMergeKeepsNConsistent: the other sketch's third compactor has the wrong lgWeight, so the merge fails after two levels. N must equal the original N plus exactly the merged weight, min must include the other's, the iterator weight must equal N, and the sketch keeps working and round-trips.KllMergeFailureTest: a dry run counts the merge's comparisons. Then, on identical seeded sketches, the comparator throws at the min comparison. Every retained item must lie within min and max, and the iterator weight must equal N.000442below min000990.javac -Xlint:all -Xdoclint:all,-missingreports nothing in the changed files.🤖 Generated with Claude Code