import "github.com/andy2046/gopie/pkg/bloom"
Package bloom implements a Bloom filter.
bloom.go bloombit.go bloomscale.go siphash.go
func Guess(n uint64, p float64) (m, k uint64)
Guess estimates m/k based on the provided n/p.
type Bloom interface {
Add([]byte)
AddString(string)
Exist([]byte) bool
ExistString(string) bool
FalsePositive() float64
GuessFalsePositive(uint64) float64
M() uint64
K() uint64
N() uint64
Clear()
}
Bloom is the standard bloom filter.
func NewB(m, k uint64) Bloom
NewB creates standard bloom filter based on the provided m/k. m is the size of bloom filter bits. k is the number of hash functions.
func NewBGuess(n uint64, p float64) Bloom
NewBGuess estimates m/k based on the provided n/p then creates standard bloom filter. n is the estimated number of elements in the bloom filter. p is the false positive probability.
func NewS(fpRate float64) Bloom
NewS creates scalable bloom filter based on the provided fpRate. fpRate is the target False Positive probability.
func NewSGuess(n uint64, p, r float64) Bloom
NewSGuess estimates m/k based on the provided n/p then creates scalable bloom filter. n is the estimated number of elements in the bloom filter. p is the false positive probability. r is the optimal tightening ratio.
type CountingBloom interface {
Bloom
Remove([]byte)
RemoveString(string)
}
CountingBloom is the bloom filter which allows deletion of entries. Take note that an 16-bit counter is maintained for each entry.
func New(m, k uint64) CountingBloom
New creates counting bloom filter based on the provided m/k. m is the size of bloom filter bits. k is the number of hash functions.
func NewGuess(n uint64, p float64) CountingBloom
NewGuess estimates m/k based on the provided n/p then creates counting bloom filter. n is the estimated number of elements in the bloom filter. p is the false positive probability.
Generated by godoc2md