in src/main/java/org/apache/datasketches/tuple/JaccardSimilarity.java [228:260]
public static <S extends Summary> boolean exactlyEqual(
final Sketch<S> sketchA,
final org.apache.datasketches.theta.Sketch sketchB,
final S summary, final SummarySetOperations<S> summarySetOps) {
// Null case checks
if (summary == null) {
throw new SketchesArgumentException("Summary cannot be null."); }
//Corner case checks
if (sketchA == null || sketchB == null) { return false; }
if (sketchA.isEmpty() && sketchB.isEmpty()) { return true; }
if (sketchA.isEmpty() || sketchB.isEmpty()) { return false; }
final int countA = sketchA.getRetainedEntries();
final int countB = sketchB.getRetainedEntries(true);
//Create the Union
final Union<S> union = new Union<>(ceilingPowerOf2(countA + countB), summarySetOps);
union.union(sketchA);
union.union(sketchB, summary);
final Sketch<S> unionAB = union.getResult();
final long thetaLongUAB = unionAB.getThetaLong();
final long thetaLongA = sketchA.getThetaLong();
final long thetaLongB = sketchB.getThetaLong();
final int countUAB = unionAB.getRetainedEntries();
//Check for identical counts and thetas
if (countUAB == countA && countUAB == countB
&& thetaLongUAB == thetaLongA && thetaLongUAB == thetaLongB) {
return true;
}
return false;
}