bloom

package
v1.2.0-fork6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func K

func K(bitsPerKey int) uint8

K calculate the best K value.

func LegacyEstimateBloomK

func LegacyEstimateBloomK(itemCount int) int

LegacyEstimateBloomK estimate k(num of hash funcs) according to item count.

Types

type Filter

type Filter struct {
	Bits []byte
	K    uint8
}

Filter the bloom filter.

func (*Filter) Contains

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

Contains to test if the given key is contained (false positive).

type Generator

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

Generator to generate variable-length bloom filter.

func (*Generator) Add

func (g *Generator) Add(key []byte)

Add add the key into bloom.

func (*Generator) Generate

func (g *Generator) Generate(bitsPerKey int, k uint8) *Filter

Generate generate variable-length bloom filter according to bits per key and count of key. The generator will be reset right after Generate.

type LegacyBloom

type LegacyBloom struct {
	Bits [legacyBitsLength / 8]byte
	K    int
}

LegacyBloom a simple bloom filter in 2048 bit length.

func NewLegacyBloom

func NewLegacyBloom(k int) *LegacyBloom

NewLegacyBloom new bloom.

func (*LegacyBloom) Add

func (b *LegacyBloom) Add(item []byte)

Add add item into bloom.

func (*LegacyBloom) Test

func (b *LegacyBloom) Test(item []byte) bool

Test test if item contained. (false positive)

Jump to

Keyboard shortcuts

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