def test_size_allocation(self):
"""Make sure we can allocate a bloom filter that would take more than
512MB (the string size limit in Redis)"""
included = sample_strings(20, 5000)
excluded = sample_strings(20, 5000)
# Add only the included strings
self.bloom.update(included)
self.assertEqual(len(included), len(self.bloom.intersection(included)))
false_positives = self.bloom.intersection(excluded)
false_rate = float(len(false_positives)) / len(excluded)
self.assertTrue(false_rate <= 0.00001,
'False positive error rate exceeded!')
# We also need to know that we can access all the keys we need
self.assertEqual(self.bloom.keys(),
[b'pyreBloomTesting.0', b'pyreBloomTesting.1'])
评论列表
文章目录