public void HllPlusPlusBigValuesMergeTest() { // Bigger values (dense representation) HyperLogLog hll2 = new HyperLogLogPlusPlus(PRECISION_DEFAULT, SPARSE_PRECISION_DEFAULT); int i; for (i = 0; i < 150000; ++i) hll1.Add(i); for (i = 100000; i < 300000; ++i) hll2.Add(i); Assert.IsTrue(hll1.Merge(hll2), "Merge should alter some registers and return true"); TestsHelper.AssertRelativeError(300000UL, hll1.Cardinality); }
public void HllPlusPlusPrecisionTest() { const ulong expected = 10000; byte[] testPrecisions = new byte[] { 4, 12, 16 }; byte[] testSparsePrecisions = new byte[] { 18, 20, 24, 25, 28, 32, 46, 52, 63 }; foreach (byte p in testPrecisions) { foreach (byte sp in testSparsePrecisions) { HyperLogLog hll = new HyperLogLogPlusPlus(p, sp); for (ulong i = 0; i < expected; ++i) hll.Add(i); TestsHelper.AssertRelativeError(expected, hll.Cardinality); } } }
public void HllPlusPlusSmallValuesMergeTest() { HyperLogLog hll2 = new HyperLogLogPlusPlus(PRECISION_DEFAULT, SPARSE_PRECISION_DEFAULT); // Small values (sparse representation) hll1.Add(1); hll1.Add(2); hll1.Add(3); hll1.Add(4); hll1.Add(4); hll2.Add(3); hll2.Add(3); hll2.Add(4); hll2.Add(5); hll2.Add(6); hll2.Add(7); hll2.Add(7); Assert.IsTrue(hll1.Merge(hll2), "Merge should alter some registers and return true"); Assert.AreEqual(7UL, hll1.Cardinality, "Cardinality after merge should be up-to-date"); }