bloom

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bloom implements a Bloom filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Guess

func Guess(n uint64, p float64) (m, k uint64)

Guess estimates m/k based on the provided n/p.

Types

type Bloom

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

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

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

func NewS(fpRate float64) Bloom

NewS creates scalable bloom filter based on the provided fpRate. fpRate is the target False Positive probability.

func NewSGuess

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

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

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL