bloom

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

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

Go to latest
Published: Jun 14, 2020 License: Apache-2.0 Imports: 1 Imported by: 8

README

Bloom Filter using double hashing.

func doubleFNV(b []byte) (uint64, uint64) {
    hx := fnv.New64()
    hx.Write(b)
    x := hx.Sum64()
    hy := fnv.New64a()
    hy.Write(b)
    y := hy.Sum64()
    return x, y
}

bf := bloom.New(1000000, 0.0001, doubleFNV)
bf.Add([]byte("hello"))
bf.Test([]byte("hello"))
bf.Test([]byte("world"))

Documentation

Overview

Package bloom implements Bloom Filter using double hashing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Add([]byte)       // add an entry to the filter
	Test([]byte) bool // test if an entry is in the filter
	Size() int        // size of the filter in bytes
	Reset()           // reset the filter to initial state
}

Filter is a generic Bloom Filter

func New

func New(n int, p float64, h func([]byte) (uint64, uint64)) Filter

New creates a classic Bloom Filter that is optimal for n entries and false positive rate of p. h is a double hash that takes an entry and returns two different hashes.

Jump to

Keyboard shortcuts

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