bloom

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashMismatch = errors.New("failed to verify hash")
	ErrNumHash      = errors.New("invalid number of hash functions, expect 0 < k < 256")
)

Functions

This section is empty.

Types

type BloomFilter

type BloomFilter interface {
	// Size of bloom filter in bits
	Size() uint64

	// NumHash is the number of hash functions used
	NumHash() uint64

	// NumElements is the number of elements in the bloom filter
	NumElements() uint64

	// Add key into bloom filter
	Add([]byte)

	// Exist checks if a key is in bloom filter
	Exist([]byte) bool

	// Bytes returns the bytes of bloom filter
	Bytes() []byte

	// FromBytes loads data into the struct
	FromBytes([]byte) error
}

BloomFilter interface

func NewBloomFilter

func NewBloomFilter(m, h uint64) (BloomFilter, error)

NewBloomFilter returns a new bloom filter

func NewBloomFilterLegacy added in v0.1.5

func NewBloomFilterLegacy(m, h uint) (BloomFilter, error)

NewBloomFilterLegacy returns a legacy new bloom filter it does not support NumElements()

Jump to

Keyboard shortcuts

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