Skip to content

Instantly share code, notes, and snippets.

@aaneja
Created August 19, 2022 18:19
Show Gist options
  • Save aaneja/709231077372750912acb25d69e77b2d to your computer and use it in GitHub Desktop.
Save aaneja/709231077372750912acb25d69e77b2d to your computer and use it in GitHub Desktop.
net.agkn.hll.HLL v. com.facebook.airlift.stats.cardinality.HyperLogLog
net.agkn.hll.HLL cardinality estimate : 100000
com.facebook.airlift.stats.cardinality.HyperLogLog cardinality estimate : 100426
@Test
public void testHLL() {
HLL hll = new HLL(25, 8, 18, true, HLLType.EMPTY);
final HyperLogLog hyperLogLog = HyperLogLog.newInstance(65536);
for (long i = 0; i < 100000L; i++) {
hll.addRaw(i);
hyperLogLog.add(i);
}
System.out.printf("%s cardinality estimate : %d%n", HLL.class.getCanonicalName(), hll.cardinality());
System.out.printf("%s cardinality estimate : %d%n", HyperLogLog.class.getCanonicalName(), hyperLogLog.cardinality());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment