ariesdevil commented on code in PR #350:
URL: https://github.com/apache/datasketches-rust/pull/350#discussion_r4545938700
##########
datasketches/src/thetafamily/common/jaccard_similarity.rs:
##########
@@ -185,6 +116,11 @@ where
return Ok(JaccardSimilarity::exact(1.0));
}
+ let union_count = union.retained_entries().len() as u64;
+ if union_count == 0 {
+ return Ok(JaccardSimilarity::new(0.0, 0.5, 1.0));
Review Comment:
Could we move this return below the two `intersection.update(...)` calls,
before compaction? A deserialized compact sketch can contain a duplicate
retained hash. If the second sketch retains no entries and its theta filters
out that hash, the union can retain zero entries. I checked this case for both
Theta and Tuple: the previous code detected the duplicate in the first input
and returned `InvalidArgument`, while this branch returns a successful estimate
of `0.5`. A regression test for that input pair would cover the distinction.
--
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]