systream / bloom-filter

Simple erlang implementation of Bloom filter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bloom filter

Simple implementation of basic Bloom filter.

Usage

Create bloom object

First you should creat a bloom object. For example create an object with max 1024 of bits.

Bloom = bloom_filter:new(1024).

Add item

Bloom1 = bloom_filter:add("test", Bloom).

Check item

maybe = bloom_filter:is_member("test", Bloom1),
false = bloom_filter:is_member("test2", Bloom1).

Probability of false positives

0 = bloom_filter:probability(Bloom1),

Bloom2 = lists:foldl(fun(I, BloomAcc) -> 
                      bloom_filter:add(I, BloomAcc) 
                      end, 
                      Bloom, 
                      lists:seq(1, 64)),
                      
12 = bloom_filter:probability(Bloom1).

About

Simple erlang implementation of Bloom filter

License:Apache License 2.0


Languages

Language:Erlang 100.0%