예제 #1
0
class TestHyperLogLog(unittest.TestCase, BasicHLLTests):
    def setUp(self):
        self.hll = HyperLogLog(16, 16)
        self.hll2 = HyperLogLog(16, 16)

    def test_a_repeated_element_is_ignored(self):
        self.hll.add_object(37)
        self.hll2.add_objects([ 37 for x in range(0, 1000) ])
        self.assertEqual(self.hll.logs, self.hll2.logs)
예제 #2
0
import logging

from hll import HyperLogLog, MartingaleHyperLogLog

logging.basicConfig(level=logging.DEBUG)

hll = HyperLogLog(10, 54)
mhll = MartingaleHyperLogLog(10, 54)

f = open('random_ints', 'r')
for l in f.readlines():
    i = int(l)
    hll.add_object(i)
    mhll.add_object(i)

print hll.unadjusted_count
print mhll.count