Repository navigation
Conversation
- The CompactTupleSketch constructor used by compact() and by the union, intersection, A-not-B and filter results sorts the entries by hash, moving each summary with its hash. Arrays passed in are never changed: if they need sorting, sorted copies are used. - CompactTupleSketch tracks whether it is ordered. A deserialized sketch is ordered if the image has the ordered flag, or holds at most one entry; otherwise it keeps the image's order. - toByteArray() sets IS_ORDERED when the sketch is ordered. - Javadoc that said results are unordered now says ordered. Java images of compact tuple sketches now match C++ byte for byte; the new check_cpp_files test compares all eight tuple_int CL files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Callers pass both arrays or neither; the check makes that explicit. 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.
Makes the Java compact tuple sketch ordered by default, as C++ is, and writes the
IS_ORDEREDflag. As a result, Java and C++ compact tuple images are now byte-identical.Problem
CompactTupleSketch.toByteArray()never setIS_ORDERED, and Java's compact tuple sketches kept hash-table order. C++ sorts by default and marks any sketch with 0 or 1 entries as ordered. So even an empty tuple image differed: flags were0x0ein Java and0x1ein C++.Changes
CompactTupleSketchconstructor sorts entries by hash, moving each summary with its hash. Every in-library result goes through it:compact(),TupleUnion,TupleIntersection,TupleAnotBandFilter.TupleAnotB.getResult()passes the operator's own hash array.CompactTupleSketchnow records whether it is ordered, through a package-privateisOrdered(). A deserialized sketch is ordered if its image has the flag or holds at most one entry. Otherwise it keeps the image's order, as with images from earlier Java releases.toByteArray()setsIS_ORDEREDwhen the sketch is ordered.JaccardSimilarityjavadoc said results are unordered; it now says they are ordered. ThePreambleUtilformat notes now describe the flag.IS_ORDERED, so this release and earlier ones accept the new images unchanged.Not in this PR: the array-of-doubles tuple sketch, which has its own compact class and image layout. A strict empty-image check in the tuple reader, as theta has, will follow in a separate PR.
Testing
CompactTupleOrderedTest:compact()is ordered, every summary stays with its hash, and the flags byte is exactly read-only | compact | ordered, plus empty when n = 0;TupleCrossLanguageTest.checkCppBytesIdentical(groupcheck_cpp_files): all eighttuple_int_n*_cpp.skCL files (n = 0 to 1,000,000) are byte-identical to Java's images. On main, all eight differ at byte 5, the flags byte.check_cpp_filesprofile passes too (17 tests).javac -Xlint:all -Xdoclint:all,-missingreports nothing in the tuple package.🤖 Generated with Claude Code