internal

package
v0.0.0-...-9540a16 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoubleFNV

func DoubleFNV(b []byte) (uint64, uint64)

simply use Double FNV here as our Bloom Filter hash

Types

type BloomRing

type BloomRing struct {
	SlotCapacity int
	SlotPosition int
	SlotCount    int
	EntryCounter int
	Slots        []Filter
}

func NewBloomRing

func NewBloomRing(slot, capacity int, falsePositiveRate float64, h func(b []byte) (uint64, uint64)) *BloomRing

NewBloomRing returns a BloomRing without mutex

func (*BloomRing) Add

func (r *BloomRing) Add(b []byte)

func (*BloomRing) Test

func (r *BloomRing) Test(b []byte) bool

type ClassicFilter

type ClassicFilter struct {
	B []byte
	K int
	H func([]byte) (uint64, uint64)
}

Classic Bloom Filter

func (*ClassicFilter) Add

func (f *ClassicFilter) Add(b []byte)

func (*ClassicFilter) Reset

func (f *ClassicFilter) Reset()

func (*ClassicFilter) Size

func (f *ClassicFilter) Size() int

func (*ClassicFilter) Test

func (f *ClassicFilter) Test(b []byte) bool

type Filter

type Filter interface {
	Add([]byte)       // add an entry to the filter
	Test([]byte) bool // test if an entry is in the filter
	Size() int        // size of the filter in bytes
	Reset()           // reset the filter to initial state
}

Filter is a generic Bloom Filter

func NewClassicFilter

func NewClassicFilter(n int, p float64, h func([]byte) (uint64, uint64)) Filter

NewClassicFilter creates a classic Bloom Filter that is optimal for n entries and false positive rate of p. H is a double hash that takes an entry and returns two different hashes.

Jump to

Keyboard shortcuts

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