Current section
Files
Jump to
Current section
Files
doc/bloom.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Module bloom</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<hr>
<h1>Module bloom</h1>
<ul class="index"><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul>
<h2><a name="index">Function Index</a></h2>
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#check-2">check/2</a></td><td>
Check for the presence of <code>Key</code> in <code>Bloom</code>.</td></tr>
<tr><td valign="top"><a href="#check_and_set-2">check_and_set/2</a></td><td>
Record the presence of <code>Key</code> in <code>Bloom</code> or <code>ForgetfulBloom</code>
and return whether it was present before.</td></tr>
<tr><td valign="top"><a href="#clear-1">clear/1</a></td><td>
Clear all of the bits in the filter, removing all keys from the set.</td></tr>
<tr><td valign="top"><a href="#deserialize-1">deserialize/1</a></td><td>
Deserialize a previously serialized bloom filter back
into a bloom filter reference.</td></tr>
<tr><td valign="top"><a href="#new-2">new/2</a></td><td>
Create a new bloom filter structure.</td></tr>
<tr><td valign="top"><a href="#new_forgetful-4">new_forgetful/4</a></td><td>
Create a new forgetful bloom filter structure.</td></tr>
<tr><td valign="top"><a href="#new_forgetful_optimal-4">new_forgetful_optimal/4</a></td><td>
Create a new forgetful bloom filter structure.</td></tr>
<tr><td valign="top"><a href="#new_optimal-2">new_optimal/2</a></td><td>
Create a new bloom filter structure.</td></tr>
<tr><td valign="top"><a href="#serialize-1">serialize/1</a></td><td>
Serialize a bloom filter to binary.</td></tr>
<tr><td valign="top"><a href="#set-2">set/2</a></td><td>
Record the presence of <code>Key</code> in <code>Bloom</code> and <code>ForgetfulBloom</code>
For <code>ForgetfulBloom</code> a boolean is returned to indicate if the value was already present (like <code>check_and_set/2</code>).</td></tr>
<tr><td valign="top"><a href="#type-1">type/1</a></td><td>
Get type of filter.</td></tr>
</table>
<h2><a name="functions">Function Details</a></h2>
<h3 class="function"><a name="check-2">check/2</a></h3>
<div class="spec">
<p><tt>check(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a> | <a href="bloom_nif.html#type-serialized_bloom">bloom_nif:serialized_bloom()</a>, Key::term()) -> boolean()</tt><br></p>
<p> </p>
</div><p>
Check for the presence of <code>Key</code> in <code>Bloom</code>.
Serialized and binary encoded bloom filters can be used with this
function when you wish to check for the key and do not need to use set
(eg. a static bloom filter stored in a database).</p>
<h3 class="function"><a name="check_and_set-2">check_and_set/2</a></h3>
<div class="spec">
<p><tt>check_and_set(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>, Key::term()) -> boolean()</tt><br></p>
<p> </p>
</div><p>
Record the presence of <code>Key</code> in <code>Bloom</code> or <code>ForgetfulBloom</code>
and return whether it was present before.</p>
<h3 class="function"><a name="clear-1">clear/1</a></h3>
<div class="spec">
<p><tt>clear(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>) -> ok</tt><br></p>
<p> </p>
</div><p>
Clear all of the bits in the filter, removing all keys from the set.</p>
<h3 class="function"><a name="deserialize-1">deserialize/1</a></h3>
<div class="spec">
<p><tt>deserialize(SerializedBloom::<a href="bloom_nif.html#type-serialized_bloom">bloom_nif:serialized_bloom()</a>) -> {ok, <a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Deserialize a previously serialized bloom filter back
into a bloom filter reference.</p>
<h3 class="function"><a name="new-2">new/2</a></h3>
<div class="spec">
<p><tt>new(BitmapSize::pos_integer(), ItemsCount::pos_integer()) -> {ok, Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Create a new bloom filter structure.
<code>BitmapSize</code> is the size in bytes (not bits) that will be allocated in memory
<code>ItemsCount</code> is an estimation of the maximum number of items to store.</p>
<h3 class="function"><a name="new_forgetful-4">new_forgetful/4</a></h3>
<div class="spec">
<p><tt>new_forgetful(BitmapSize::pos_integer(), ItemsCount::pos_integer(), NumFilters::pos_integer(), RotateAfter::pos_integer()) -> {ok, Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Create a new forgetful bloom filter structure.
<code>BitmapSize</code> is the size in bytes (not bits) that will be allocated in memory
<code>ItemsCount</code> is an estimation of the maximum number of items to store,
<code>NumFilters</code> is the number of filters to maintain (minimum of 3) and
<code>RotateAfter</code> is how many insertions to do into a filter before rotating a blank filter into the <code>future</code> position.</p>
<h3 class="function"><a name="new_forgetful_optimal-4">new_forgetful_optimal/4</a></h3>
<div class="spec">
<p><tt>new_forgetful_optimal(ItemsCount::pos_integer(), NumFilters::pos_integer(), RotateAfter::pos_integer(), FalsePositiveRate::float()) -> {ok, Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Create a new forgetful bloom filter structure.
<code>BitmapSize</code> is the size in bytes (not bits) that will be allocated in memory
<code>ItemsCount</code> is an estimation of the maximum number of items to store,
<code>NumFilters</code> is the number of filters to maintain (minimum of 3) and
<code>RotateAfter</code> is how many insertions to do into a filter before rotating a blank filter into the <code>future</code> position.
<code>FalsePositiveRate</code> is the wanted rate of false positives, in [0.0, 1.0].</p>
<h3 class="function"><a name="new_optimal-2">new_optimal/2</a></h3>
<div class="spec">
<p><tt>new_optimal(ItemsCount::pos_integer(), FalsePositiveRate::float()) -> {ok, Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Create a new bloom filter structure.
<code>ItemsCount</code> is an estimation of the maximum number of items to store.
<code>FalsePositiveRate</code> is the wanted rate of false positives, in [0.0, 1.0].</p>
<h3 class="function"><a name="serialize-1">serialize/1</a></h3>
<div class="spec">
<p><tt>serialize(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>) -> {ok, <a href="bloom_nif.html#type-serialized_bloom">bloom_nif:serialized_bloom()</a>}</tt><br></p>
<p> </p>
</div><p>
Serialize a bloom filter to binary.
<code>check/2</code> can be used against this serialized form efficiently.</p>
<h3 class="function"><a name="set-2">set/2</a></h3>
<div class="spec">
<p><tt>set(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>, Key::term()) -> ok | boolean()</tt><br></p>
<p> </p>
</div><p>
Record the presence of <code>Key</code> in <code>Bloom</code> and <code>ForgetfulBloom</code>
For <code>ForgetfulBloom</code> a boolean is returned to indicate if the value was already present (like <code>check_and_set/2</code>).</p>
<h3 class="function"><a name="type-1">type/1</a></h3>
<div class="spec">
<p><tt>type(Bloom::<a href="bloom_nif.html#type-bloom">bloom_nif:bloom()</a>) -> number() | {error, Reason::binary()}</tt><br></p>
<p> </p>
</div><p>
Get type of filter.</p>
<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc</i></p>
</body>
</html>