Help us shape the future of Go! Take the 2026 Go Developer Survey

bloom

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxFilterHashFuncs is the maximum number of hash functions of bloom filter.
	MaxFilterHashFuncs = 256

	// MaxFilterSize is the maximum byte size in bytes a filter may be.
	MaxFilterSize = 1024 * 1024

	// DefaultConflictRate is the default conflict rate for any key.
	DefaultConflictRate = 0.0001
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Matches(data []byte) bool
	Add(data []byte)
	MatchesAndAdd(data []byte) bool
	Merge(f Filter) error
	Reset()
	Copy(f Filter) error

	Size() uint32
	K() uint32
	Tweak() uint32
	FPRate() float64
	GetByte(i uint32) byte
	Indexes() []uint32
	IsEmpty() bool

	conv.Serializable
}

Filter defines bloom filter interface

func LoadFilter

func LoadFilter(data []byte) (Filter, error)

LoadFilter loads bloom filter from serialized data.

func NewFilter

func NewFilter(elements uint32, fprate float64) Filter

NewFilter returns a Filter

func NewFilterWithMK

func NewFilterWithMK(m uint32, k uint32) Filter

NewFilterWithMK returns a Filter. M is the cap of the bloom filter K is the number of hash functions

func NewFilterWithMKAndTweak

func NewFilterWithMKAndTweak(m uint32, k uint32, tweak uint32) Filter

NewFilterWithMKAndTweak returns a Filter with specific tweak for hash seed. M is the cap of the bloom filter K is the number of hash functions

func NewFilterWithTweak

func NewFilterWithTweak(elements uint32, fprate float64, tweak uint32) Filter

NewFilterWithTweak returns a Filter with with specific tweak for hash seed

Jump to

Keyboard shortcuts

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