cuckoofilter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketSize

func BucketSize(s uint8) option

BucketSize sets the size of each bucket in the filter. Defaults to 4.

func FingerprintSize

func FingerprintSize(s uint8) option

FingerprintSize sets the size of the fingerprint. Defaults to 2.

func HashFn

func HashFn(hashfn hash.Hash) option

HashFn sets the hashing function to be used for fingerprinting. Defaults to a 64-bit FNV-1 hash.Hash.

func MaximumKicks

func MaximumKicks(k uint) option

MaximumKicks sets the maximum number of times we kick down items/displace from their buckets. Defaults to 500.

func Size

func Size(s uint) option

Size sets the number of buckets in the filter. Defaults to ((1 << 18) / BucketSize).

Types

type CFilter

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

func NewCuckooFilter

func NewCuckooFilter(opts ...option) *CFilter

New returns a new CFilter object. It's Insert, Lookup, Delete and Size behave as their names suggest. Takes zero or more of the following option functions and applies them in order to the Filter:

  • cuckoofilter.Size(uint) sets the number of buckets in the filter
  • cuckoofilter.BucketSize(uint8) sets the size of each bucket
  • cuckoofilter.FingerprintSize(uint8) sets the size of the fingerprint
  • cuckoofilter.MaximumKicks(uint) sets the maximum number of bucket kicks
  • cuckoofilter.HashFn(hash.Hash) sets the fingerprinting hashing function

func (*CFilter) Count

func (f *CFilter) Count() uint

Count returns the total number of elements currently in the Cuckoo Filter.

func (*CFilter) Delete

func (f *CFilter) Delete(item []byte) bool

Delete removes an element (in byte-array form) from the Cuckoo Filter, returns true if element existed prior and false otherwise.

func (*CFilter) Insert

func (f *CFilter) Insert(item []byte) bool

Insert adds an element (in byte-array form) to the Cuckoo filter, returns true if successful and false otherwise.

func (*CFilter) Lookup

func (f *CFilter) Lookup(item []byte) bool

Lookup checks if an element (in byte-array form) exists in the Cuckoo Filter, returns true if found and false otherwise.

type CuckooFilter

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

func New

func New(opts ...option) *CuckooFilter

func (*CuckooFilter) Count

func (f *CuckooFilter) Count() uint

func (*CuckooFilter) Delete

func (f *CuckooFilter) Delete(item []byte) bool

func (*CuckooFilter) Insert

func (f *CuckooFilter) Insert(item []byte) bool

func (*CuckooFilter) Lookup

func (f *CuckooFilter) Lookup(item []byte) bool

func (*CuckooFilter) Update

func (f *CuckooFilter) Update(filter *CFilter)

Jump to

Keyboard shortcuts

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