python-bloomfilter
python-bloomfilter copied to clipboard
How do I save my bloom filter to a file?
Is there somehow I can store my full bloom filter to a file and load it again later on to check for new values?
Did you try the Pickle module of Python? The object serialization can achieve your goal.
@HOuaghad @leopeng1995 Pickle is likely to be the good choice for this purpose but there are two ready-to-use methods come along with the package.
sbf = ScalableBloomFilter(mode=ScalableBloomFilter.SMALL_SET_GROWTH)
with open('file_path' ,'w+') as fh:
sbf.tofile(fh)
with open('/home/joseph/text.txt', 'r') as fh:
sbf_from_file = ScalableBloomFilter.fromfile(fh)
Always use ScalableBloomFilter
.
My branch has tweaked configuration for tightening ration and growth rate.