bloom

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 5 Imported by: 10

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
}

BloomFilter interface

func BloomFilterFromBytes

func BloomFilterFromBytes(buf []byte) (BloomFilter, error)

BloomFilterFromBytes constructs a bloom filter from bytes

func BloomFilterFromBytesLegacy added in v0.1.5

func BloomFilterFromBytesLegacy(b []byte, m, h uint) (BloomFilter, error)

BloomFilterFromBytesLegacy constructs a bloom filter from bytes

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