Esempio n. 1
0
    def size_check(self, log_counting=None, width_adjustment=1):
        data_set = [(1, 2**15, 8), (2, 2**16, 8), (3, 2**16, 12),
                    (4, 2**17, 8), (5, 2**17, 10), (6, 2**17, 12),
                    (7, 2**17, 14), (8, 2**18, 8), (32, 2**20, 8),
                    (55, 2**20, 13), (95, 2**21, 11), (256, 2**23, 8)]

        for (size_mb, width, depth) in data_set:
            cms = CountMinSketch(size_mb, log_counting=log_counting)
            self.assertEqual(cms.width, width * width_adjustment,
                             "Width for size %d" % size_mb)
            self.assertEqual(cms.depth, depth, "Depth for size %d" % size_mb)
            self.assertLessEqual(cms.size(), size_mb * 1024 * 1024)
            self.assertGreater(cms.size(), size_mb * 1024 * 1024 / 2)
Esempio n. 2
0
 def test_depth_alg_init(self):
     data_set = [(None, 4, 2**18, 4), (None, 17, 2**19, 8),
                 (1024, 70, 2**21, 17), (8, 100, 2**26, 1)]
     for (log_counting, size_mb, exp_width, depth) in data_set:
         cms = CountMinSketch(size_mb=size_mb,
                              depth=depth,
                              log_counting=log_counting)
         self.assertEqual(cms.width, exp_width)
         self.assertEqual(cms.depth, depth)
         self.assertLessEqual(cms.size(), size_mb * 1024 * 1024)
Esempio n. 3
0
 def test_width_depth_alg_init(self):
     data_set = [(None, 2**12, 3, 49152), (None, 2**13, 7, 229376),
                 (1024, 2**18, 1, 524288), (8, 2**13, 7, 57344)]
     for (log_counting, width, depth, size) in data_set:
         cms = CountMinSketch(width=width,
                              depth=depth,
                              log_counting=log_counting)
         self.assertEqual(cms.width, width)
         self.assertEqual(cms.depth, depth)
         self.assertLessEqual(cms.size(), size)