bloom

package
v0.0.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateParameters

func EstimateParameters(n uint64, p float64) (m uint, k uint)

EstimateParameters estimates m and k from n and p

func GenHashInts

func GenHashInts(seed []byte, n int) []uint

GenHashInts generate n hash values by the seed passed

func Hash512

func Hash512(data []byte) []byte

Hash512 return the sha512 of the data passed

Types

type Filter

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

Filter is an implementation of bloom filter

func New

func New(m, k uint) *Filter

New creates a new Filter with m bits and k hash functions

func NewFromData

func NewFromData(data []byte) *Filter

NewFromData creates a new Filter from data generated by fn 'Data()'

func NewWithEstimates

func NewWithEstimates(n uint64, fp float64) *Filter

NewWithEstimates creates a new Filter with n and fp. n is the capacity of the Filter fp is the tolerated error rate of the Filter

func (*Filter) Add

func (bf *Filter) Add(val string)

Add adds val to the Filter

func (*Filter) Contains

func (bf *Filter) Contains(val string) bool

Contains returns true if val is (high probability) in the Filter, otherwise returns false.

func (*Filter) Data

func (bf *Filter) Data() []byte

Data returns the data of the Filter, it can bee used to creates a new Filter by using fn 'NewFromData' .

Jump to

Keyboard shortcuts

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