python-bloomfilter icon indicating copy to clipboard operation
python-bloomfilter copied to clipboard

How do I save my bloom filter to a file?

Open derrandz opened this issue 8 years ago • 2 comments

Is there somehow I can store my full bloom filter to a file and load it again later on to check for new values?

derrandz avatar Jun 17 '16 16:06 derrandz

Did you try the Pickle module of Python? The object serialization can achieve your goal.

leopeng1995 avatar Sep 25 '16 05:09 leopeng1995

@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.

joseph-fox avatar Sep 25 '16 12:09 joseph-fox