Implementing a Cuckoo Filter in Go
medium.com
medium.com
it would be so much more readable if the struct had more descriptive names
type Cuckoo struct {
buckets []bucket
numBuckets uint
entriesPerBucket uint
fingerprintLength uint
capacity uint
}In the end, I went with the shorter variable names as they are used in the paper I've linked: https://www.pdl.cmu.edu/PDL-FTP/FS/cuckoo-conext2014.pdf
In a production version of this, longer variable names would be a good thing. :)
package main
import (
"crypto/sha1"
"hash"
"sync"
)
func main() {
hasher := getHasher()
defer poolHasher(hasher)
}
var hasherPool sync.Pool = sync.Pool{
New: func() interface{} {
return sha1.New()
},
}
func getHasher() hash.Hash {
return hasherPool.Get().(hash.Hash)
}
func poolHasher(hasher hash.Hash) {
hasher.Reset()
hasherPool.Put(hasher)
}