bbloom

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidParms = errors.New("One of parameters was outside of allowed range")
View Source
var ErrUsage = errors.New("usage: New(float64(number_of_entries), float64(number_of_hashlocations)) i.e. New(float64(1000), float64(3)) or New(float64(number_of_entries), float64(ratio_of_false_positives)) i.e. New(float64(1000), float64(0.03))")

Functions

This section is empty.

Types

type Bloom

type Bloom struct {
	Mtx sync.RWMutex
	// contains filtered or unexported fields
}

Bloom filter

func JSONUnmarshal

func JSONUnmarshal(dbData []byte) *Bloom

JSONUnmarshal takes JSON-Object (type bloomJSONImExport) as []bytes returns bloom32 / bloom64 object

func New

func New(params ...float64) (bloomfilter *Bloom, err error)

New returns a new bloomfilter

func NewWithBoolset

func NewWithBoolset(bs *[]byte, locs uint64) (bloomfilter *Bloom)

NewWithBoolset takes a []byte slice and number of locs per entry returns the bloomfilter with a bitset populated according to the input []byte

func (*Bloom) Add

func (bl *Bloom) Add(entry []byte)

Add set the bit(s) for entry; Adds an entry to the Bloom filter

func (*Bloom) AddIfNotHas

func (bl *Bloom) AddIfNotHas(entry []byte) (added bool)

AddIfNotHas Only Add entry if it's not present in the bloomfilter returns true if entry was added returns false if entry was allready registered in the bloomfilter

func (*Bloom) AddIfNotHasTS

func (bl *Bloom) AddIfNotHasTS(entry []byte) (added bool)

AddIfNotHasTS Tread safe: Only Add entry if it's not present in the bloomfilter returns true if entry was added returns false if entry was allready registered in the bloomfilter

func (*Bloom) AddTS

func (bl *Bloom) AddTS(entry []byte)

AddTS Thread safe: Mutex.Lock the bloomfilter for the time of processing the entry

func (*Bloom) Clear

func (bl *Bloom) Clear()

Clear resets the Bloom filter

func (*Bloom) ElementsAdded

func (bl *Bloom) ElementsAdded() uint64

func (*Bloom) FillRatio

func (bl *Bloom) FillRatio() float64

func (*Bloom) Has

func (bl *Bloom) Has(entry []byte) bool

Has check if bit(s) for entry is/are set returns true if the entry was added to the Bloom Filter

func (*Bloom) HasTS

func (bl *Bloom) HasTS(entry []byte) bool

HasTS Thread safe: Mutex.Lock the bloomfilter for the time of processing the entry

func (*Bloom) JSONMarshal

func (bl *Bloom) JSONMarshal() ([]byte, error)

JSONMarshal returns JSON-object (type bloomJSONImExport) as []byte

Jump to

Keyboard shortcuts

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