Documentation ¶
Overview ¶
Package bloomfilter provides a simple bloom filter implementation for the GoLang programming language. This package includes the ability to create a new bloom filter from an estimated optimal size and optimal number of hash functions for the specified estimated max number of items to be set in the bloom filter as well as the maximum tolerable failure rate
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BloomFilter ¶
type BloomFilter interface { // Add adds a value to the bloom filter Add(string) // Check checks to see if a value has been added to the bloom filter. // Check returns true if it thinks the value has been added and false // if it thinks the value has not been added. Check(string) bool }
BloomFilter is a probabilistic data structure that will always return false if the value is not present but will sometimes return true if the value has not been set. BloomFilter is space-efficient, however, items cannot be deleted.
func New ¶
func New(m, k int64) BloomFilter
New returns a new instance of BloomFilter NewBloomFilter accepts m and k as arguments where m is the size of the bloom filter and k is the number of hashing functions.
func NewFromEstimate ¶
func NewFromEstimate(expectedNumberOfItems int64, maxFPRate float64) BloomFilter
NewFromEstimate returns a new instance of BloomFilter from an estimate of the required size of the bloom filter as well as an estimate of the optimal hash functions for the estimated number of items in the bloom filter NewBloomFilterFromEstimate takes in expectedNumberOfItems and maxFPRate as arguments where expectedNumberOfItems is the max number of items expected to be set in the bloom filter and maxFPRate is the max rate of failure tolerable for the filter