cuckoo

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 7 Imported by: 0

README

Cuckoo

Implementing a Cuckoo filter, based on the paper Cuckoo Filter: Practically Better Than Bloom

Example Usage

package main

import(
	"log"
	"github.com/arriqaaq/cuckoo"
)

func main(){
	f := cuckoo.NewCuckooFilter(uint(5000000), 0.001)
	n1 := []byte("Bess")
	err := f.Insert(n1)
	if err!=nil{
		log.Println("bucket full: ",err)
	}
	isPresent := f.Lookup(n1)
	log.Println("key present? ",isPresent)

}

Performance

			BenchmarkCuckooAdd-4          	 2000000	      1008 ns/op
			BenchmarkCuckooTest-4         	 2000000	       685 ns/op
			BenchmarkCuckooTestAndAdd-4   	 1000000	      1780 ns/op
			BenchmarkCuckooLookupAndDelete-4 2000000	       796 ns/op

Reference

TODO

  • Make it thread safe
  • Improve hashing time, need to optimize on Insertion function

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_FILTER_FULL = errors.New("full")
)

Functions

This section is empty.

Types

type CuckooFilter

type CuckooFilter struct {
	// contains filtered or unexported fields
}

func NewCuckooFilter

func NewCuckooFilter(capacity uint, fpRate float64) *CuckooFilter

func (*CuckooFilter) Delete

func (c *CuckooFilter) Delete(data []byte) bool

func (*CuckooFilter) Insert

func (c *CuckooFilter) Insert(data []byte) error

func (*CuckooFilter) Lookup

func (c *CuckooFilter) Lookup(data []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL