Simple Bloom Filter implement by golang Bloom Filter is the simple and space-efficient probabilistic data structure to check the data is exist or not. but Bloom Filter have the false positive rate. false positive rate mean the data is not in the set or storage but Bloom Filter return true. This implement is the Count Bloom Filter provide
- Add element to Bloom Filter
- Query element from Bloom Filter
- Remove element from Bloom Filter
Use the murmur3 hash as the Bloom Filter hash function
go get github.com/Noahnut/blf
expectFalsePositiveRate := 0.5
// contruct the bloomFilter with expect element number and False Positive Rate
blf := ContructbloomFilter(100, expectFalsePositiveRate)
// Add the AAAA to the bloom filter
blf.Add([]byte("AAAA"))
// return true "AAAA" exist in the bloom filter
blf.Query([]byte("AAAA"))
// return false "BBB" not exist in the bloom filter
blf.Query([]byte("BBB"))
// remove "AAAA" from the bloom filter
blf.Delete([]byte("AAAA"))
// return false "AAAA" not exist in the bloom filter
blf.Query([]byte("AAAA"))