func CPUTicks() int64
CPUTicks is a faster alternative to NanoTime to measure time duration.
func FastRand() uint32
FastRand is a fast thread local random function.
func KeyToHash(key interface{}) (uint64, uint64)
TODO: Figure out a way to re-use memhash for the second uint64 hash, we
already know that appending bytes isn't reliable for generating a second hash (see Ristretto PR #88). We also know that while the Go runtime has a runtime memhash128 function, it's not possible to use it to generate [2]uint64 or anything resembling a 128bit hash, even though that's exactly what we need in this situation.
func MemHash(data []byte) uint64
MemHash is the hash function used by go map, it utilizes available hardware instructions(behaves as aeshash if aes instruction is available). NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.
func MemHashString(str string) uint64
MemHashString is the hash function used by go map, it utilizes available hardware instructions (behaves as aeshash if aes instruction is available). NOTE: The hash seed changes for every process. So, this cannot be used as a persistent hash.
func NanoTime() int64
NanoTime returns the current time in nanoseconds from a monotonic clock.
Bloom filter
type Bloom struct { ElemNum uint64 // contains filtered or unexported fields }
func JSONUnmarshal(dbData []byte) (*Bloom, error)
JSONUnmarshal takes JSON-Object (type bloomJSONImExport) as []bytes returns bloom32 / bloom64 object.
func NewBloomFilter(params ...float64) (bloomfilter *Bloom)
NewBloomFilter returns a new bloomfilter.
func (bl *Bloom) Add(hash uint64)
Add adds hash of a key to the bloomfilter.
func (bl *Bloom) AddIfNotHas(hash uint64) bool
AddIfNotHas only Adds hash, if it's not present in the bloomfilter. Returns true if hash was added. Returns false if hash was already registered in the bloomfilter.
func (bl *Bloom) Clear()
Clear resets the Bloom filter.
func (bl Bloom) Has(hash uint64) bool
Has checks if bit(s) for entry hash is/are set, returns true if the hash was added to the Bloom Filter.
func (bl *Bloom) IsSet(idx uint64) bool
IsSet checks if bit[idx] of bitset is set, returns true/false.
func (bl Bloom) JSONMarshal() []byte
JSONMarshal returns JSON-object (type bloomJSONImExport) as []byte.
func (bl *Bloom) Set(idx uint64)
Set sets the bit[idx] of bitset.
func (bl *Bloom) Size(sz uint64)
Size makes Bloom filter with as bitset of size sz.