moolb

Bloom filter for python3 with pluggable hasher backend
git clone git://git.defalsify.org/python-moolb.git
Log | Files | Refs | README | LICENSE

commit 10b4c6cff5a0c4e8445f556dffc7d5f7bcef42e9
parent e3dfcb4be8e3c8ad72b0cddf4c6506ec0003469e
Author: nolash <dev@holbrook.no>
Date:   Thu, 29 Oct 2020 21:57:38 +0100

pluggable hashes

Diffstat:
Mmain.py | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/main.py b/main.py @@ -7,6 +7,8 @@ logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() +# m = ceil((n * log(p)) / log(1 / pow(2, log(2)))); + class BloomFilter: def __init__(self, bits, rounds): @@ -16,7 +18,11 @@ class BloomFilter: raise ValueError('Need byte boundary bit value') self.rounds = rounds self.filter = numpy.zeros(self.bytes, dtype=numpy.uint8) - self.hasher = self.__hash + self.hasher = self.set_hasher(self.__hash) + + + def set_hasher(self, hasher): + self.hasher = hasher def add(self, b):