https://github.com/kuba--/cuckoo
Cuckoo Filter: Practically Better Than Bloom
https://github.com/kuba--/cuckoo
bloom cuckoo cuckoo-filter golang hashing
Last synced: 19 days ago
JSON representation
Cuckoo Filter: Practically Better Than Bloom
- Host: GitHub
- URL: https://github.com/kuba--/cuckoo
- Owner: kuba--
- License: mit
- Created: 2017-03-21T15:25:18.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-21T22:33:33.000Z (about 2 years ago)
- Last Synced: 2025-03-26T14:01:45.391Z (about 1 month ago)
- Topics: bloom, cuckoo, cuckoo-filter, golang, hashing
- Language: Go
- Size: 15.6 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://godoc.org/github.com/kuba--/cuckoo)
[](https://goreportcard.com/report/github.com/kuba--/cuckoo)
[](https://github.com/kuba--/cuckoo/actions?query=workflow%3Abuild)# Cuckoo Filter: Practically Better Than Bloom
Package _cuckoo_ provides a Cuckoo Filter (Practically Better Than Bloom).
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.Implementation is based heavily on whitepaper: "Cuckoo Filter: Better Than Bloom" by Bin Fan, Dave Andersen and Michael Kaminsky
(https://www.cs.cmu.edu/~dga/papers/cuckoo-conext2014.pdf).### Example
```go
var item []byte// Create a new filter with 32MB capacity
f := cuckoo.NewFilter(32 * 1024 * 1024)if f.Lookup(item) {
if !f.Delete(item) {
// Cannot delete the item
// ...
}
} else {
if err := f.Insert(item); err != nil {
// Hashtable is considered full
// ...
}
}
```### Fuzzing - randomized testing
- get go-fuzz
```
$ go get github.com/dvyukov/go-fuzz/go-fuzz
$ go get github.com/dvyukov/go-fuzz/go-fuzz-build
```- build the test program with necessary instrumentation
```
$ go-fuzz-build github.com/kuba--/cuckoo/fuzz/cuckoo
```- ready to go
```
$ go-fuzz -bin=./cuckoo-fuzz.zip -workdir=/tmp/cuckoo
```