feat(theta): add jaccard similarity - #142
Conversation
|
We also miss |
tisonkun
left a comment
There was a problem hiding this comment.
We must not have a unit struct ThetaJaccardSimilarity for creating JaccardSimilarity.
Let me consider the API and review the helper functions location.
Typically, here are a few API issues that should be resolved:
- Should have
JaccardSimilarity::between/JaccardSimilarity::between_with_seed, rather thanThetaJaccardSimilarity::jaccard/ThetaJaccardSimilarity::jaccard_with_seed. JaccardSimilarityshould expose its internal fields with getter, not pub fields, because the fields are immutatble.
…/datasketches-rust into feat/theta-jaccard-similarity
|
Addressed the API feedback from @tisonkun:
The tests have been updated to use the new API. |
…to feat/theta-jaccard-similarity
|
@ZENOTME I have two questions:
|
Java has a specific update implementation, AlphaSketch, where theta can be reduced without immediately rebuilding the internal cache. This means some cached entries may become invalid under the new theta but remain in the cache until a later rebuild. Therefore, getRetainedEntries(true) returns the valid entries used for estimation, while getRetainedEntries(false) returns the raw internal cache count, including possibly invalid entries.
We don't have ThetaUnion so far. I think it maybe better to implement it first. I send a PR for it. #145 cc @tisonkun @hawkingrei |
|
I think this implementation should also using |
|
@hawkingrei @ZENOTME @ariesdevil You may coordinate to see how to move forward this feature. |
|
As @ZENOTME mentioned, this PR should rebase first, then do the same thing as union and intersection. |
|
Or simply creating a new one. I'd leave @hawkingrei this week for doing the (logical) rebase work, or else anyone can pick it up. |
|
Updated the branch onto current The Jaccard implementation now follows the same shape as the C++
Validated locally with Could you please take another look at the updated API and shared-operation structure? |
|
@ZENOTME Implemented your shared raw-layer direction in
This makes the common layer ready for Tuple reuse when its public Jaccard API is added, without expanding this PR beyond Theta. Could you please review the updated structure? |
tisonkun
left a comment
There was a problem hiding this comment.
We should implement JaccardSimilarity for tuple sketch to see what should be extract to thetacommon.
This patch is a good starting point while I may have issues with:
RawThetaJaccardSimilarityshould be renamed toJaccardSimilarityfollows other methods.RawThetaJaccardSimilarity's fields should be private.between_with_seedlooks weird. I suppose we should followANotBOperator's design.
|
Implemented the requested Jaccard design changes in
Local validation passed:
The two remaining inline review threads have been answered and resolved. Please take another look when convenient. |
|
Thank you @tisonkun, @ariesdevil, and @ZENOTME for the careful review and design guidance. I incorporated the feedback in
The repository-required local workflows ( Could you please take another look when convenient? Thanks again for helping improve the API and abstraction boundary. |
tisonkun
left a comment
There was a problem hiding this comment.
This is now mergable.
But we need to support other methods like:
- exactly_equal
- similarity_test
- dissimilarity_test
... later.
Summary
Motivation
This closes a parity gap with the Apache DataSketches Jaccard implementations while keeping seed validation and Theta-family set semantics consistent with the existing Rust operators.
Related implementation: apache/datasketches-cpp Jaccard similarity
Implementation Notes
ThetaJaccardSimilarityandTupleJaccardSimilarityas configured operators; the seed is selected when constructing the operator.iter_hashesto the internal Theta-family view so Tuple similarity does not clone summary payloads.[0.0, 0.5, 1.0]result.Tests
All required repository workflows pass locally:
cargo x prepare-testdatacargo x checkcargo x testcargo x lintThe test suite covers Theta and Tuple mutable/compact inputs, different Tuple summary values and types, exact and estimation modes, custom seeds, seed mismatches, and zero-retained uncertainty.