forked from gray/bloomerl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gregory Burd
committed
Jun 20, 2012
1 parent
d30133a
commit dd05cff
Showing
8 changed files
with
75 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
|
||
{application, bloomerl, | ||
[ | ||
{description, "Bloom filters"}, | ||
{vsn, "1.0.0"}, | ||
{registered, []}, | ||
{applications, [ | ||
kernel, | ||
stdlib | ||
]}, | ||
{applications, [kernel, stdlib ]}, | ||
{mod, {bloomerl_app, []}}, | ||
{env, []} | ||
]}. | ||
{env, [ | ||
{lager, [ | ||
{handlers, [ | ||
{lager_console_backend, info}, | ||
{lager_file_backend, [ | ||
{"error.log", error, 10485760, "$D0", 5}, | ||
{"console.log", info, 10485760, "$D0", 5} | ||
]} | ||
]} | ||
]} | ||
]} | ||
]}. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
%% @hidden | ||
-module(bloom_tests). | ||
-compile(export_all). | ||
|
||
-include_lib("eunit/include/eunit.hrl"). | ||
|
||
all_my_test_() -> | ||
[ {"Should create a bloom filter", fun should_create_a_bloom_filter/0} | ||
, {"Should be sized correctly", fun should_be_sized_correctly/0} | ||
, {"Should contain one element", fun should_contain_one_element/0} | ||
]. | ||
|
||
should_create_a_bloom_filter() -> | ||
Bloom = bloom:new(5, 0.001), | ||
true = bloom:is_bloom(Bloom), | ||
false = bloom:is_bloom({foo}). | ||
|
||
should_be_sized_correctly() -> | ||
Bloom1 = bloom:new(5, 0.1), | ||
32 = bloom:filter_size(Bloom1), | ||
Bloom2 = bloom:new(5, 0.01), | ||
48 = bloom:filter_size(Bloom2), | ||
Bloom3 = bloom:new(5), % default is 0.001 | ||
72 = bloom:filter_size(Bloom3), | ||
Bloom4 = bloom:new(5, 0.0001), | ||
96 = bloom:filter_size(Bloom4). | ||
|
||
should_contain_one_element() -> | ||
Bloom = bloom:new(5, 0.01), | ||
0 = bloom:count(Bloom), | ||
Bloom1 = bloom:add_element(<<"abcdef">>, Bloom), | ||
Bloom1 = bloom:add_element(<<"abcdef">>, Bloom), | ||
1 = bloom:count(Bloom1), | ||
true = bloom:is_element(<<"abcdef">>, Bloom1), | ||
false = bloom:is_element(<<"zzzzzz">>, Bloom1), | ||
Bloom2 = bloom:clear(Bloom1), | ||
0 = bloom:count(Bloom2), | ||
false = bloom:is_element(<<"abcdef">>, Bloom2), | ||
false = bloom:is_element(<<"zzzzzz">>, Bloom2). | ||
|
||
|
||
%% Helper functions | ||
|
||
%% fold_lines(FileName, Fun) -> | ||
%% {ok, Device} = file:open(FileName, [read]), | ||
%% fold_over_lines(Device, Fun). | ||
|
||
%% fold_over_lines(Device, Fun) -> | ||
%% case io:get_line(Device, "") of | ||
%% eof -> | ||
%% file:close(Device); | ||
%% Line -> | ||
%% Fun(Line), fold_over_lines(Device, Fun) | ||
%% end. |
This file was deleted.
Oops, something went wrong.