Bloomex v1.2.0 Bloomex View Source
This module implements a Scalable Bloom Filter.
Examples
iex> bf = Bloomex.scalable(1000, 0.1, 0.1, 2)
%Bloomex.ScalableBloom...
iex> bf = Bloomex.add(bf, 5)
%Bloomex.ScalableBloom...
iex> Bloomex.member?(bf, 5)
true
iex> bf = Bloomex.add(bf, 100)
%Bloomex.ScalableBloom...
iex> Bloomex.member?(bf, 100)
true
iex> Bloomex.member?(bf, 105)
false
iex> Bloomex.member?(bf, 101) # false positive
true
Link to this section Summary
Functions
Returns a bloom filter with the element e added.
Returns the capacity of the bloom filter.
Returns true if the element e exists in the bloom filter, otherwise returns false.
Returns a plain Bloom filter based on the provided arguments
Returns a scalable Bloom filter based on the provided arguments
Returns the number of elements currently in the bloom filter.
Link to this section Types
Link to this section Functions
Returns a bloom filter with the element e added.
Returns the capacity of the bloom filter.
A plain bloom filter will always have a fixed capacity, while a scalable one will always have a theoretically infite capacity.
deserialise(bloom, func \\ fn x -> :erlang.phash2(x, 1 <<< 32) end)
View Sourcedeserialize(bloom, func \\ fn x -> :erlang.phash2(x, 1 <<< 32) end)
View SourceReturns true if the element e exists in the bloom filter, otherwise returns false.
Keep in mind that you may get false positives, but never false negatives.
plain(capacity, error, hash_func \\ fn x -> :erlang.phash2(x, 1 <<< 32) end)
View Sourceplain(integer(), float(), hash_func()) :: Bloomex.Bloom.t()
Returns a plain Bloom filter based on the provided arguments:
capacity, used to calculate the size of each bitvector sliceerror, the error probabilityhash_func, a hashing function
If a hash function is not provided then :erlang.phash2/2 will be used with
the maximum range possible (2^32).
Restrictions:
capacitymust be a positive integererrormust be a float between0and1hash_funcmust be a function of typeterm -> pos_integer
The function follows a rule of thumb due to double hashing where
capacity >= 4 / error must hold true.
scalable(capacity, error, error_ratio, growth, hash_func \\ fn x -> :erlang.phash2(x, 1 <<< 32) end)
View Sourcescalable(integer(), number(), number(), 1 | 2 | 3, hash_func()) :: Bloomex.ScalableBloom.t()
Returns a scalable Bloom filter based on the provided arguments:
capacity, the initial capacity before expandingerror, the error probabilityerror_ratio, the error probability ratiogrowth, the growth ratio when fullhash_func, a hashing function
If a hash function is not provided then :erlang.phash2/2 will be used with
the maximum range possible (2^32).
Restrictions:
capacitymust be a positive integererrormust be a float between0and1error_ratiomust be a float between0and1growthmust be a positive integer between1and3hash_funcmust be a function of typeterm -> pos_integer
The function follows a rule of thumb due to double hashing where
capacity >= 4 / (error * (1 - error_ratio)) must hold true.
See Bloomex.serialise/1.
Returns the number of elements currently in the bloom filter.