bloom

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLargeOffset = errors.New("too large offset")

ErrTooLargeOffset indicates the offset is too large in bitset.

Functions

This section is empty.

Types

type Filter

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

A Filter is a bloom filter.

func New

func New(store *redis.Redis, key string, bits uint) *Filter

New create a Filter, store is the backed redis, key is the key for the bloom filter, bits is how many bits will be used, maps is how many hashes for each addition. best practices: elements - means how many actual elements when maps = 14, formula: 0.7*(bits/maps), bits = 20*elements, the error rate is 0.000067 < 1e-4 for detailed error rate table, see http://pages.cs.wisc.edu/~cao/papers/summary-cache/node8.html

func (*Filter) Add

func (f *Filter) Add(data []byte) error

Add adds data into f.

func (*Filter) Exists

func (f *Filter) Exists(data []byte) (bool, error)

Exists checks if data is in f.

Jump to

Keyboard shortcuts

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