bloom

package module
v0.0.0-...-3d94ea1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 8 Imported by: 0

README

Bloom filter

Test Go Report Card Go Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func K

func K(m, n uint32) uint32

K calculates number of hash functions m is a size of bitset n is an expected number of elements

func M

func M(n int, p float64) uint32

M calculates size of bitset n is an expected number of elements p is a false alarm probability

Types

type Bloom

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

Bloom is an implementation of bloom filter

func New

func New(n int, p float64) *Bloom

New create a new instance of the bloom filter n is expected number of elements p is false alarm probability

func (*Bloom) Add

func (b *Bloom) Add(k []byte)

Add the key to the bloom filter k is the key of the element

func (*Bloom) Contains

func (b *Bloom) Contains(k []byte) bool

Contains checks for the presence of an element in the bloom filter k is the key of the element

func (*Bloom) ReadFrom

func (b *Bloom) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads the bloom filter from the reader

func (*Bloom) Union

func (b *Bloom) Union(a *Bloom) (err error)

Union two different bloom filters with the same size and number of hash functions

func (*Bloom) WriteTo

func (b *Bloom) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the bloom filter in a writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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