Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFull = errors.New("filter is at its max capacity")
ErrFull is returned when Add is called while the filter is at max capacity.
Functions ¶
This section is empty.
Types ¶
type QuotientFilter ¶
type QuotientFilter struct {
// contains filtered or unexported fields
}
QuotientFilter is a basic quotient filter implementation. None of the methods are thread safe.
func New ¶
func New(q, r uint8) *QuotientFilter
New returns a QuotientFilter with q quotient bits and r remainder bits. it can hold 1 << q elements.
func NewHash ¶
func NewHash(h hash.Hash64, q, r uint8) *QuotientFilter
NewHash returns a QuotientFilter backed by a different hash function. Default hash function is FNV-64a
func NewProbability ¶
func NewProbability(capacity int, probability float64) *QuotientFilter
NewProbability returns a quotient filter that can accomidate capacity number of elements and maintain the probability passed.
func (*QuotientFilter) Add ¶
func (qf *QuotientFilter) Add(key string) error
Add adds the key to the filter.
func (*QuotientFilter) AddAll ¶
func (qf *QuotientFilter) AddAll(keys []string) error
AddAll adds multiple keys to the filter
func (*QuotientFilter) Contains ¶
func (qf *QuotientFilter) Contains(key string) bool
Contains checks if key is present in the filter false positive probability is based on q, r and number of added keys false negatives are not possible, unless Delete is used in conjunction with a hash function that yields more that q+r bits.
func (*QuotientFilter) FPProbability ¶
func (qf *QuotientFilter) FPProbability() float64
FPProbability returns the probability for false positive with the current fillrate n = length m = capacity a = n / m r = remainder bits then probability for false positive is 1 - e^(-a/2^r) <= 2^-r