bloom

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Estimate

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

Estimate returns an estimated bit count and hash count given the element count and false positive rate.

Types

type Filter

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

Filter represents a bloom filter.

func NewFilter

func NewFilter(m uint64, k uint64) *Filter

NewFilter returns a new instance of Filter using m bits and k hash functions. If m is not a power of two then it is rounded to the next highest power of 2.

func NewFilterBuffer

func NewFilterBuffer(buf []byte, k uint64) (*Filter, error)

NewFilterBuffer returns a new instance of a filter using a backing buffer. The buffer length MUST be a power of 2.

func (*Filter) Bytes

func (f *Filter) Bytes() []byte

Bytes returns the underlying backing slice.

func (*Filter) Clone added in v1.4.0

func (f *Filter) Clone() *Filter

Clone returns a copy of f.

func (*Filter) Contains

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

Contains returns true if the filter possibly contains v. Returns false if the filter definitely does not contain v.

func (*Filter) Insert

func (f *Filter) Insert(v []byte)

Insert inserts data to the filter.

func (*Filter) K

func (f *Filter) K() uint64

K returns the number of hash functions used in the filter.

func (*Filter) Len

func (f *Filter) Len() uint

Len returns the number of bits used in the filter.

func (*Filter) Merge

func (f *Filter) Merge(other *Filter) error

Merge performs an in-place union of other into f. Returns an error if m or k of the filters differs.

Jump to

Keyboard shortcuts

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