布隆过滤器 的一个好处就是可以一个bit表示一个数据,
下面有一个python的开源库
https://axiak.github.io/pybloomfiltermmap/ref.html
构造函数:
class pybloomfilter.BloomFilter(capacity : int, error_rate : float, filename : string)
这个filename是生成的bloomfilter文件,可以用open读进来
static BloomFilter.open(filename)
Open an already existing Bloomfilter file.
打开一个bloomfilter的文件。调用这个函数之前,必须要生成一个bloomfilter文件。
BloomFilter.add(item) → Boolean
可以用 is inbloomfilter 来判断是否在过滤器中,更详细的调用请看网站。
这里有一个C版本的过滤器
https://github.com/ArashPartow/bloom/blob/master/bloom_filter.hpp