Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.34 KB

README.md

File metadata and controls

39 lines (30 loc) · 1.34 KB

GitHub license Build Status

Bloom Filter

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

  1. Add element to Bloom Filter
  2. Query element from Bloom Filter
  3. Remove element from Bloom Filter

Detail

Use the murmur3 hash as the Bloom Filter hash function

Install

go get github.com/Noahnut/blf

Usage

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"))