pbloom

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

func FromSerialized

func FromSerialized(data []byte) (*Filter, error)

FromSerialized deserializes a Bloom filter from a byte slice using MessagePack.

func NewFilterFromBits

func NewFilterFromBits(bits []byte, k uint8) (*Filter, error)

NewFilterFromBits initializes a Bloom filter from an existing bit slice and specified number of hash functions. This can be useful when deserializing or reconstructing a Bloom filter from stored data.

func NewFilterFromEntriesAndFP

func NewFilterFromEntriesAndFP(entries int, fpRate float64) (*Filter, error)

NewFilterFromEntriesAndFP initializes a Bloom filter with a specified number of entries and desired false positive rate. It calculates the necessary size (in bytes) and the optimal number of hash functions (K).

func NewFilterFromEntriesAndSize

func NewFilterFromEntriesAndSize(entries int, size int) (*Filter, error)

NewFilterFromEntriesAndSize initializes a Bloom filter with a specified number of entries and storage size in bytes. It calculates the optimal number of hash functions (K) based on the provided parameters.

func (*Filter) Exists

func (f *Filter) Exists(key []byte) bool

Exists checks whether a key is possibly in the Bloom filter. Returns true if the key might be in the set, or false if it is definitely not present.

func (*Filter) Put

func (f *Filter) Put(key []byte)

Put inserts a key into the Bloom filter by setting the appropriate bits.

func (*Filter) Serialize

func (f *Filter) Serialize() ([]byte, error)

Serialize serializes the Bloom filter into a byte slice using MessagePack.

Jump to

Keyboard shortcuts

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