Documentation ¶
Overview ¶
Package cfilter is an implementation of the Cuckoo filter, a Bloom filter replacement for approximated set-membership queries. Cuckoo filters support adding and removing items dynamically while achieving even higher performance than Bloom filters.
As documented in the original implementation:
Cuckoo filters provide the flexibility to add and remove items dynamically. A cuckoo filter is based on cuckoo hashing (and therefore named as cuckoo filter). It is essentially a cuckoo hash table storing each key's fingerprint. Cuckoo hash tables can be highly compact, thus a cuckoo filter could use less space than conventional Bloom filters, for applications that require low false positive rates (< 3%).
For details about the algorithm and citations please refer to the original research paper, "Cuckoo Filter: Better Than Bloom" by Bin Fan, Dave Andersen and Michael Kaminsky (https://www.cs.cmu.edu/~dga/papers/cuckoo-conext2014.pdf).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BucketSize ¶ added in v0.1.1
func BucketSize(s uint8) option
BucketSize sets the size of each bucket in the filter. Defaults to 4.
func FingerprintSize ¶ added in v0.1.1
func FingerprintSize(s uint8) option
FingerprintSize sets the size of the fingerprint. Defaults to 2.
func HashFn ¶ added in v0.1.1
HashFn sets the hashing function to be used for fingerprinting. Defaults to a 64-bit FNV-1 hash.Hash.
func MaximumKicks ¶ added in v0.1.1
func MaximumKicks(k uint) option
MaximumKicks sets the maximum number of times we kick down items/displace from their buckets. Defaults to 500.
Types ¶
type CFilter ¶
type CFilter struct {
// contains filtered or unexported fields
}
CFilter represents a Cuckoo Filter, a probabilistic data store for approximated set membership queries.
func New ¶ added in v0.1.1
func New(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:
- cfilter.Size(uint) sets the number of buckets in the filter
- cfilter.BucketSize(uint8) sets the size of each bucket
- cfilter.FingerprintSize(uint8) sets the size of the fingerprint
- cfilter.MaximumKicks(uint) sets the maximum number of bucket kicks
- cfilter.HashFn(hash.Hash) sets the fingerprinting hashing function
func (*CFilter) Count ¶ added in v0.1.1
Count returns the total number of elements currently in the Cuckoo Filter.
func (*CFilter) DecodeBuckets ¶ added in v0.2.4
DecodeBunckets decode from an existed filter. reader is a stream from EncodeBuckets Must having same option with another one
func (*CFilter) Delete ¶
Delete removes an element (in byte-array form) from the Cuckoo Filter, returns true if element existed prior and false otherwise.