项目作者: kuba--

项目描述 :
Cuckoo Filter: Practically Better Than Bloom
高级语言: Go
项目地址: git://github.com/kuba--/cuckoo.git
创建时间: 2017-03-21T15:25:18Z
项目社区:https://github.com/kuba--/cuckoo

开源协议:MIT License

下载


GoDoc
Go Report Card
Build Status

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

  1. var item []byte
  2. // Create a new filter with 32MB capacity
  3. f := cuckoo.NewFilter(32 * 1024 * 1024)
  4. if f.Lookup(item) {
  5. if !f.Delete(item) {
  6. // Cannot delete the item
  7. // ...
  8. }
  9. } else {
  10. if err := f.Insert(item); err != nil {
  11. // Hashtable is considered full
  12. // ...
  13. }
  14. }

Fuzzing - randomized testing

  • get go-fuzz

    1. $ go get github.com/dvyukov/go-fuzz/go-fuzz
    2. $ go get github.com/dvyukov/go-fuzz/go-fuzz-build
  • build the test program with necessary instrumentation

    1. $ go-fuzz-build github.com/kuba--/cuckoo/fuzz/cuckoo
  • ready to go

    1. $ go-fuzz -bin=./cuckoo-fuzz.zip -workdir=/tmp/cuckoo