Documentation
¶
Overview ¶
Package cuckoo ...
Implements a CuckooFilter that uses cuckoo hashing to provide fast set membership testing.
Index ¶
- type ConfigOption
- type Filter
- func (f *Filter) Delete(item []byte) bool
- func (f *Filter) Insert(item []byte) bool
- func (f *Filter) InsertUnique(item []byte) bool
- func (f *Filter) ItemCount() uint
- func (f *Filter) Lookup(item []byte) bool
- func (f *Filter) MarshalBinary() ([]byte, error)
- func (f *Filter) Save(path string) error
- func (f *Filter) UnmarshalBinary(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigOption ¶
type ConfigOption func(*Filter)
ConfigOption ...
Composed Filter function type used for configuring a Filter
func BucketEntries ¶
func BucketEntries(entries uint) ConfigOption
BucketEntries ...
Number of entries per bucket denoted as b ¶
Example:
New(BucketEntries(uint(42)))
func BucketTotal ¶
func BucketTotal(total uint) ConfigOption
BucketTotal ...
Number of buckets in the Filter denoted as m ¶
Example:
New(BucketTotal(uint(42)))
func FingerprintLength ¶
func FingerprintLength(length uint) ConfigOption
FingerprintLength ...
Length of the item fingerprint denoted as f ¶
Example:
New(FingerprintLength(uint(4)))
func Kicks ¶
func Kicks(kicks uint) ConfigOption
Kicks ...
Maximum number of kicks to attempt when bucket collisions occur ¶
Example:
New(Kicks(uint(200)))
type Filter ¶
Filter ...
Cuckoo filter type
func New ¶
func New(opts ...ConfigOption) (filter *Filter)
New ...
Create a new Filter with an optional set of ConfigOption to configure settings.
Example: New Filter with custom config option
New(FingerprintLength(4))
Example: New Filter with default config
New()
returns a Filter type
func (*Filter) Delete ¶
Delete ...
Delete an item of []byte if it exists in the Filter
Example:
filter.Delete([]byte("new-item"))
returns a boolean of whether the item was deleted or not
func (*Filter) Insert ¶
Insert ...
Add a new item of []byte to a Filter
Example:
filter.Insert([]byte("new-item"))
returns a boolean of whether the item was inserted or not
func (*Filter) InsertUnique ¶
InsertUnique ...
Add a new item of []byte to a Filter only if it doesn't already exist. Will do a Lookup of item first.
Example:
filter.InsertUnique([]byte("new-item"))
returns a boolean of whether the item was inserted or not
func (*Filter) ItemCount ¶
ItemCount ...
Get an estimate of the total items in the Filter. Could be drastically off if using Insert with many duplicate items. To get a more accurate total using InsertUnique can be used
Example:
filter.ItemCount()
returns an uint of the total items in the Filter
func (*Filter) Lookup ¶
Lookup ...
Check if an item of []byte exists in the Filter
Example:
filter.Lookup([]byte("new-item"))
returns a boolean of whether the item exists or not
func (*Filter) MarshalBinary ¶
MarshalBinary used to interact with gob encoding interface
func (*Filter) UnmarshalBinary ¶
UnmarshalBinary modifies the receiver so it must take a pointer receiver. Used to interact with gob encoding interface