bloom

package
v1.3.27 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateParameters

func EstimateParameters(n uint64, p float64) (m uint64, k uint64)

EstimateParameters estimates m and k from n and p

Types

type BloomFilter

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

BloomFilter is an implementation of bloom filter

func New

func New(m, k uint64, opts ...Option) *BloomFilter

New creates a new BloomFilter with m bits and k hash functions

func NewFromData

func NewFromData(data []byte, opts ...Option) *BloomFilter

NewFromData creates a new BloomFilter from data generated by function 'Data()'

func NewWithEstimates

func NewWithEstimates(n uint64, fp float64, opts ...Option) *BloomFilter

NewWithEstimates creates a new BloomFilter with n and fp. n is the capacity of the BloomFilter fp is the tolerated error rate of the BloomFilter

func (*BloomFilter) Add

func (bf *BloomFilter) Add(val string)

Add adds val to the BloomFilter

func (*BloomFilter) Contains

func (bf *BloomFilter) Contains(val string) bool

Contains returns true if val is (high probability) in the BloomFilter, otherwise returns false.

func (*BloomFilter) Data

func (bf *BloomFilter) Data() []byte

Data returns the data of the BloomFilter, it can bee used to creates a new BloomFilter by using function 'NewFromData' .

type Option

type Option func(opt *Options)

Option is a function type used to set Options

func WithGoroutineSafe

func WithGoroutineSafe() Option

WithGoroutineSafe is used to config a BloomFilter with goroutine-safe

type Options

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

Options holds BloomFilter's options

Jump to

Keyboard shortcuts

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