Repository navigation
Align theta and tuple JaccardSimilarity; check theta seeds in tuple set operations - #782
Merged
Merged
Conversation
…le set operations Theta JaccardSimilarity: - Add seed overloads of jaccard, exactlyEqual, similarityTest and dissimilarityTest, as in C++ and Go. Sketches created with a custom seed previously could not be compared at all. Tuple JaccardSimilarity: - Share the union and identical-sets code through private helpers, as theta does, replacing four copies. - Clamp the union size in exactlyEqual to the legal range of nominal entries, as tuple jaccard, theta, C++ and Go already do. - Return early when jaccard is given the same sketch twice. Tuple set operations: - TupleUnion, TupleIntersection and TupleAnotB now reject a non-empty ThetaSketch created with a non-default seed. Tuple sketches always use the default seed, so such input previously gave silently wrong results. - ThetaSketch.getSeedHash() is now public, as get_seed_hash() is in C++. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #778. It brings the Java theta and tuple
JaccardSimilarityclasses into line with each other, and with C++ (theta_jaccard_similarity_base.hpp) and Go (tuple/jaccard_similarity.go), which share one implementation for theta and tuple.Theta
JaccardSimilarityjaccard,exactlyEqual,similarityTestanddissimilarityTest. Until now, sketches created with a custom seed couldn't be compared: the internal union and intersection used the default seed and threw "Incompatible Seed Hashes". The existing methods pass the default seed through, so callers see no change.Tuple
JaccardSimilaritycomputeUnion,newUnionandidenticalSets, as theta has since Fix JaccardSimilarity.exactlyEqual throwing for small theta sketches #778. They replace four copies of the union-and-compare code.exactlyEqualto the legal range of nominal entries, as tuplejaccard, theta, C++ and Go already do. Unlike theta, tuple never threw here, because tuple sketches don't enforce the range; the change is for consistency.jaccard(TupleSketch, TupleSketch, ...), as in theta, C++ and Go.Tuple set operations with a
ThetaSketchinputTupleUnion.union,TupleIntersection.intersect,TupleAnotB.notBandTupleAnotB.aNotBnow throwSketchesArgumentExceptionwhen given a non-emptyThetaSketchcreated with a non-default seed. Java tuple sketches always use the default seed, so such input used to give silently wrong results. Empty sketches aren't checked, as in theta.ThetaSketch.getSeedHash()is now public, matchingget_seed_hash()in C++.Full custom-seed support for Java tuple sketches, as C++, Go and Rust have, is planned as a separate PR.
Tests
tuple/ThetaSeedHashTest, plus new tests in bothJaccardSimilarityTestclasses. The seed-rejection tests fail without this change.mvn verifypasses: 2298 tests, plus the javadoc and style checks.🤖 Generated with Claude Code