standard

package
v0.0.0-...-8beb243 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateParameters

func EstimateParameters(n uint, e float64) (uint64, uint64)

EstimateParameters estimates requirements for m and k.

Based on: https://en.wikipedia.org/wiki/Bloom_filter#Optimal_number_of_hash_functions

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter represents a Standard Bloom filter.

func New

func New(m, k uint64, hashFns []types.Hash) *Filter

New returns a new pointer to a Standard Bloom filter.

func NewWithEstimates

func NewWithEstimates(n uint, e float64, hashFns []types.Hash) *Filter

NewWithEstimates returns a pointer to a standard Bloom filter with the given number of items and false positive rate.

func (*Filter) Add

func (f *Filter) Add(item []byte)

Add adds an item to the Bloom filter.

func (*Filter) ApproximateCount

func (f *Filter) ApproximateCount() int

ApproximateCount returns the approximate number of items in the Bloom filter.

Based on: https://en.wikipedia.org/wiki/Bloom_filter#Approximating_the_number_of_items_in_a_Bloom_filter

func (*Filter) Cap

func (f *Filter) Cap() uint64

Cap returns the capacity of the Bloom filter.

func (*Filter) Clear

func (f *Filter) Clear()

Clear clears the Bloom filter.

func (*Filter) Contains

func (f *Filter) Contains(item []byte) bool

Contains returns true if the item is in the Bloom filter.

func (*Filter) CurrentFalsePositiveRate

func (f *Filter) CurrentFalsePositiveRate() float64

CurrentFalsePositiveRate returns the current false positive rate of the Bloom filter.

Based on: https://en.wikipedia.org/wiki/Bloom_filter#Probability_of_false_positives

func (*Filter) K

func (f *Filter) K() uint64

K returns the number of hash functions used.

Jump to

Keyboard shortcuts

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