Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Cuckoo Filter: Practically better than bloom filter

License

NotificationsYou must be signed in to change notification settings

vedhavyas/cuckoo-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Practically better than Bloom Filter. Cuckoo filters support adding and removing items dynamically while achieving even higher performance than Bloom filters. For applications that store many items and target moderately low false positive rates, cuckoo filters have lower space overhead than space-optimized Bloom filters. It is a compact variant of a cuckoo hashtable that stores only fingerprints—a bit string derived from the item using a hash function—for each item inserted, instead of key-value pairs. The filter is densely filled with fingerprints (e.g., 95% entries occupied), which confers high space efficiency.

Paper can be foundhere.

--import "github.com/vedhavyas/cuckoo-filter"

Usage

type Filter

typeFilterstruct {}

Filter is the cuckoo-filter

func NewFilter

funcNewFilter(countuint32)*Filter

func StdFilter

funcStdFilter()*Filter

StdFilter returns Standard Cuckoo-Filter

func (*Filter) Count

func (f*Filter)Count()uint32

Count returns total inserted items into filter

func (*Filter) Delete

func (f*Filter)Delete(x []byte)bool

Delete deletes the item from the filter

func (*Filter) Insert

func (f*Filter)Insert(x []byte)bool

Insert inserts the item to the filter returns error of filter is full

func (*Filter) InsertUnique

func (f*Filter)InsertUnique(x []byte)bool

InsertUnique inserts only unique items

func (*Filter) LoadFactor

func (f*Filter)LoadFactor()float64

LoadFactor returns the load factor of the filter

func (*Filter) Lookup

func (f*Filter)Lookup(x []byte)bool

Lookup says if the given item exists in filter

func (*Filter) Encode

func (f*Filter)Encode(w io.Writer)error

Encode gob encodes the filter to passed writer

func Decode

funcDecode(r io.Reader) (*Filter,error)

Decode decodes and returns the filter instance

Benchmarks

16 << 20 inserts with bucket size 4

Maximum Inserts=================Expected inserts: 16777216Total inserted: 16022242Load factor: 0.9550Time Taken: 18.118615793s=================Lookups=================Total lookups: 16022242Failed lookups: 0Expected failed lookups: 0Load factor: 0.9550Time Taken: 11.394561881s=================

16 << 20 inserts with bucket size 8

Maximum Inserts=================Expected inserts: 16777216Total inserted: 16525558Load factor: 0.9850Time Taken: 17.478650065s=================Lookups=================Total lookups: 16525558Failed lookups: 0Expected failed lookups: 0Load factor: 0.9850Time Taken: 12.087359139s=================

16 << 20 inserts with max bucket size(16)

Maximum Inserts=================Expected inserts: 16777216Total inserted: 16676553Load factor: 0.9940Time Taken: 16.280342789s=================Lookups=================Total lookups: 16676553Failed lookups: 0Expected failed lookups: 0Load factor: 0.9940Time Taken: 12.45013918s=================

About

Cuckoo Filter: Practically better than bloom filter

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp