Module bloom

Bloom Filter implementation.

Copyright © 2011-2016 Zuse Institute Berlin

Version: $Id$

Authors: Maik Lange (malange@informatik.hu-berlin.de).

References

Description

Bloom Filter implementation

Data Types

bloom_filter()

abstract datatype: bloom_filter()

key()

key() = any()

Function Index

add/2Adds one item to the bloom filter.
add_list/2Adds multiple items to the bloom filter.
calc_FPR/3Calculates FP for an M-bit large bloom filter with K hash funtions and a maximum number of N elements.
calc_HF_num_Size_opt/2Calculates the optimal number of hash functions K and Bloom filter size M when K = ln(2)*M/N and M = N * log_2(1/FP) / ln(2) with N elements and a false positive probability FP.
calc_least_size/3Calculates the number of bits needed by a bloom filter to have a false positive probability of FP using K hash functions and up to N-Elements.
equals/2Checks whether two bloom filters are equal.
get_property/2
is_element/2Returns true if the bloom filter contains this item.
item_count/1Gets the number of items inserted into this bloom filter.
join/2Joins two bloom filter so that the returned bloom filter represents their union.
new/2Creates a new bloom filter.
new_bin/3Creates a new bloom filter with the given binary, hash function set and item count.
new_bpi/3Creates a new bloom filter with the given hash function set and a fixed number of bits per item.
new_fpr/2Creates a new bloom filter with the default (optimal) hash function set based on the given false positive rate.
new_fpr/3Creates a new bloom filter with the given hash function set based on the given false positive rate.
p_add_positions/3
print/1Returns bloom filter debug information.
resize/2Increases Val until Val rem Div == 0.

Function Details

new_fpr/2

new_fpr(MaxItems :: non_neg_integer(), FPR :: float()) ->
           bloom_filter()

Creates a new bloom filter with the default (optimal) hash function set based on the given false positive rate.

new_fpr/3

new_fpr(MaxItems :: non_neg_integer(),
        FPR :: float(),
        Hfs :: hfs_plain:hfs() | non_neg_integer()) ->
           bloom_filter()

Creates a new bloom filter with the given hash function set based on the given false positive rate.

new_bpi/3

new_bpi(MaxItems :: non_neg_integer(),
        BitsPerItem :: number(),
        Hfs :: hfs_plain:hfs() | non_neg_integer()) ->
           bloom_filter()

Creates a new bloom filter with the given hash function set and a fixed number of bits per item.

new_bin/3

new_bin(Filter :: bitstring(),
        HfCount :: hfs_plain:hfs() | non_neg_integer(),
        ItemsCount :: non_neg_integer()) ->
           bloom_filter()

Creates a new bloom filter with the given binary, hash function set and item count.

new/2

new(BitSize :: pos_integer(),
    HfCount :: hfs_plain:hfs() | non_neg_integer()) ->
       bloom_filter()

Creates a new bloom filter.

add/2

add(Bloom :: bloom_filter(), Item :: key()) -> bloom_filter()

Adds one item to the bloom filter.

add_list/2

add_list(Bloom :: bloom_filter(), Items :: [key()]) ->
            bloom_filter()

Adds multiple items to the bloom filter.

p_add_positions/3

p_add_positions(Positions :: [non_neg_integer(), ...],
                BF1 :: bitstring(),
                BFSize :: pos_integer()) ->
                   BF2 :: bitstring()

is_element/2

is_element(Bloom :: bloom_filter(), Item :: key()) -> boolean()

Returns true if the bloom filter contains this item.

item_count/1

item_count(Bloom :: bloom_filter()) -> non_neg_integer()

Gets the number of items inserted into this bloom filter.

join/2

join(Bloom :: bloom_filter(), BF2 :: bloom_filter()) ->
        bloom_filter()

Joins two bloom filter so that the returned bloom filter represents their union.

equals/2

equals(Bloom :: bloom_filter(), X2 :: bloom_filter()) -> boolean()

Checks whether two bloom filters are equal.

print/1

print(Bloom :: bloom_filter()) -> [{atom(), any()}]

Returns bloom filter debug information.

get_property/2

get_property(Bloom :: bloom_filter(), X2 :: fpr) -> float()

calc_HF_num_Size_opt/2

calc_HF_num_Size_opt(N :: non_neg_integer(), FP :: float()) ->
                        {K :: pos_integer(), M :: pos_integer()}

Calculates the optimal number of hash functions K and Bloom filter size M when K = ln(2)*M/N and M = N * log_2(1/FP) / ln(2) with N elements and a false positive probability FP.

calc_least_size/3

calc_least_size(N :: non_neg_integer(),
                FP :: float(),
                K :: pos_integer()) ->
                   M :: pos_integer()

Calculates the number of bits needed by a bloom filter to have a false positive probability of FP using K hash functions and up to N-Elements. M = 1/(1-(1-(FP)^(1/K))^(1/(KN)))

calc_FPR/3

calc_FPR(M :: pos_integer(),
         N :: non_neg_integer(),
         K :: pos_integer()) ->
            FP :: float()

Calculates FP for an M-bit large bloom filter with K hash funtions and a maximum number of N elements. FP = (1-(1-1/M)^(K*N))^K

resize/2

resize(Val :: non_neg_integer(), Div :: pos_integer()) ->
          NewVal :: non_neg_integer()

Increases Val until Val rem Div == 0.


Generated by EDoc, Aug 2 2016, 13:42:08.