kkdai / bloomfilter

A space-efficient probabilistic data structure Bloom Filter implement by Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bloom Filter

GitHub license GoDoc Build Status

Bloom Filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970.

This implement is experimental to written Golang to prove the basic concept of Bloom Filter.

Install

go get github.com/kkdai/bloomfilter

Usage

    //Create a couting bloom filter expect size 100, false detect rate 0.01
	cbf := NewCountingBloomFilter(100, 0.01)
	
	//Add item into cbf
	cbf.Add([]byte("foo"))
	cbf.Add([]byte("john"))
	cbf.Add([]byte("tom"))

	//test 
	fmt.Println("Test cbf:", cbf.Test([]byte("tom"))) //return "true"

    //Remvoe item from cbf
	cbf.Remove([]byte("john"))
	
	//test again
	fmt.Println("Test cbf:", cbf.Test([]byte("john"))) //return "false"

Inspired

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

About

A space-efficient probabilistic data structure Bloom Filter implement by Golang

License:MIT License


Languages

Language:Go 100.0%