tisonkun opened a new pull request, #357: URL: https://github.com/apache/datasketches-rust/pull/357
## Summary Follow up on #350 to refine error semantics, execution cost, threshold helpers, and the public surface of Jaccard similarity across Theta and Tuple sketches in four focused commits: 1. **Error semantics (`fix(theta,tuple): return InvalidArgument on Jaccard seed mismatch`)**: Report seed-hash mismatches in Jaccard `compute` and `exactly_equal` as `ErrorKind::InvalidArgument` instead of `ErrorKind::InvalidData` (which is reserved for malformed serialized payloads), matching `ThetaUnion`, `ThetaIntersection`, `ThetaANotB`, and their Tuple counterparts, and validate the supplied `seed` before taking empty-input fast paths. 2. **Direct count evaluation (`perf(theta,tuple): compute Jaccard counts without IntersectionState`)**: Compute `(union_theta, union_count, intersection_count)` directly without building an `IntersectionState` hash table or materializing intermediate compact vectors. Pairs of mutable hash tables, pairs of ordered compact sketches, and mixed mutable/ordered pairs up to `2^26` combined entries now run with zero heap allocations; unordered compact inputs and oversized pairs fold per-source provenance bits in a single `UnionState` (inserting the lower-theta sketch first). `exactly_equal` also short-circuits in `O(1)` when `theta` or `num_retained` differ after seed validation. 3. **Hypothesis-test helpers (`feat(common): add similarity threshold tests to JaccardSimilarity`)**: Add `JaccardSimilarity::is_similar(threshold)` (`lower_bound >= threshold`) and `JaccardSimilarity::is_dissimilar(threshold)` (`upper_bound <= threshold`) for one-sided 97.7% confidence tests on an already-computed `JaccardSimilarity` value, returning `ErrorKind::InvalidArgument` when `threshold` is outside `[0.0, 1.0]` or `NaN`. 4. **Unified stateless API (`refactor(theta,tuple): unify Jaccard API on JaccardSimilarity across Theta and Tuple`)**: Replace the duplicate `ThetaJaccardSimilarity` and `TupleJaccardSimilarity` seed-wrapper structs with associated functions on `datasketches::common::JaccardSimilarity` (`compute`, `compute_with_seed`, `exactly_equal`, and `exactly_equal_with_seed`) accepting any `JaccardSketch` (`&ThetaSketch`, `&CompactThetaSketch`, `ThetaSketchView`, `&TupleSketch<P>`, `&CompactTupleSketch<S>`, and `TupleSketchView`), enabling direct cross-Theta/Tuple comparisons without summary or policy boilerplate. ## Validation * `cargo x check` * `cargo x lint` * `cargo x test` * `cargo x bench --no-run` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
