bwdb

package module
v0.0.0-...-a79a8d6 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

README

go-bloom

A very simple fast bloom filter with Add, Test, Save, and Load methods.

Create and test

  filter := bloom.Filter{make([]byte, 100)}
  filter.Add([]byte("hello"))
  hit := filter.TestString("hello")

To save or load data, use the filter.Data slice.

Benchmarks

$ go test --bench=.
goos: linux
goarch: amd64
cpu: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
BenchmarkAdd-12                 40322137                26.81 ns/op
BenchmarkAddString-12           32753798                38.91 ns/op
BenchmarkTest-12                44796183                24.68 ns/op
BenchmarkTestString-12          40576682                27.15 ns/op
PASS

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Data []byte
}

func (*Filter) Add

func (f *Filter) Add(d []byte) (hash uint64)

Add a byte slice to the filter

func (*Filter) AddString

func (f *Filter) AddString(s string) (hash uint64)

Add a string to the filter

func (*Filter) Fold

func (w *Filter) Fold(n int) error

Fold will reduce the memory resident size by a factor n

func (*Filter) Test

func (f *Filter) Test(d []byte) bool

Test if a byte slice may be in the filter

func (*Filter) TestString

func (f *Filter) TestString(s string) bool

Test if the string may be in the filter

Jump to

Keyboard shortcuts

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