Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public static double[] jaccard(final ThetaSketch sketchA, final ThetaSketch sket
/**
* Returns true if the two given sketches have exactly the same hash values and the same
* theta values. Thus, they are equivalent.
*
* <p>Note: For very large pairs of sketches, where the configured nominal entries of the sketches
* are 2^26, this method may return false even if the two sketches are equal.
*
* @param sketchA the given sketch A
* @param sketchB the given sketch B
* @return true if the two given sketches have exactly the same hash values and the same
Expand All @@ -116,8 +120,11 @@ public static boolean exactlyEqual(final ThetaSketch sketchA, final ThetaSketch
final int countB = sketchB.getRetainedEntries(true);

//Create the ThetaUnion
final int minK = 1 << ThetaUtil.MIN_LG_NOM_LONGS;
final int maxK = 1 << ThetaUtil.MAX_LG_NOM_LONGS;
final int newK = max(min(ceilingPowerOf2(countA + countB), maxK), minK);
final ThetaUnion union =
ThetaSetOperation.builder().setNominalEntries(ceilingPowerOf2(countA + countB)).buildUnion();
ThetaSetOperation.builder().setNominalEntries(newK).buildUnion();
union.union(sketchA);
union.union(sketchB);
final ThetaSketch unionAB = union.getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ public void checkMinK() {
println(result[0] + ", " + result[1] + ", " + result[2]);
}

@Test
public void checkMinKExactlyEqual() {
UpdatableThetaSketch skA = UpdatableThetaSketch.builder().build(); //4096
UpdatableThetaSketch skB = UpdatableThetaSketch.builder().build(); //4096
skA.update(1);
skB.update(1);
assertTrue(exactlyEqual(skA, skB));
skB.update(2);
assertFalse(exactlyEqual(skA, skB));
}

@Test
public void printlnTest() {
println("PRINTING: "+this.getClass().getName());
Expand Down