- 🏢 Building things at Amplemarket
- 🔧 Mostly using Ruby, Rails, Redis, Postgres
- 📫 @gmcabrita
gmcabrita / bloomex Goto Github PK
View Code? Open in Web Editor NEW:hibiscus: A pure Elixir implementation of Scalable Bloom Filters
License: MIT License
:hibiscus: A pure Elixir implementation of Scalable Bloom Filters
License: MIT License
I'm currently dissatisfied with a subset of the API being used, most specifically:
new/2
new/3
new/5
new_plain_bloom/3
new
currently denotes the creation of a Scalable Bloom filter, and new_plain_bloom
the creation of a plain Bloom filter.
My current idea is to discard both new/2
and new/3
, forcing the user to understand what kind of parameters he's actually using in this Bloom filter.
The function naming is also ambiguous so I'm changing that as well.
Current proposed API:
plain/2
, uses the default hash function
plain/3
, the user specifies everything
scalable/4
, uses the default hash function
scalable/5
, the user specifies everything
In the new API plain
will denote a regular Bloom filter and scalable
a Scalable Bloom filter.
It appears that the capacity of the plain bloom filter may be calculated incorrectly. This example
bloom = Bloomex.plain(1000, 0.01)
Enum.reduce(1..1000, bloom, &Bloomex.add(&2, &1))
results in the following bloom filter struct
%Bloomex.Bloom{
bv: [
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
{:array, 1, 0, 0, {3, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
],
error_prob: 0.01,
hash_func: #Function<1.7646300/1 in Bloomex.plain/2>,
max: 1,
mb: 1,
size: 3
}
It appears that only 3 distinct numbers were actually added to the filter, even though it was initialized with a capacity of 1000 and a false positive rate of 1%. This configuration would be expected to hold around 990 distinct keys. It also seems wrong that the :max
field is being set to 1 in this configuration.
If the above configuration is incorrect, or if I am misunderstanding the calculations for the plain filter, please let me know.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.