/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Bloom-Filter/blib/html/site/lib/Bloom/Filter.html


DESCRIPTION</pre> <p>A Bloom filter is a probabilistic algorithm for doing existence tests in less memory than a full list of keys would require. The tradeoff to using Bloom filters is a certain configurable risk of false positives. This module implements a simple Bloom filter with configurable capacity and false positive rate. Bloom filters were first described in a 1970 paper by Burton Bloom, see <a href=``http://portal.acm.org/citation.cfm?id=362692&dl=ACM&coll=portal''>http://portal.acm.org/citation.cfm.</p> <p> </p> <hr /> <h1><a name=``synopsis''>SYNOPSI/a</h1> <pre> use Bloom::Filter</pre> <pre> <span class=``keyword''>my</span> <span class=``variable''>$bf</span> <span class=``operator''>=</span> <span class=``variable''>Bloom::Filter</span><span class=``operator''>-&gt;</span><span class=``variable''>new</span><span class=``operator''>(</span> <span class=``string''>capacity</span> <span class=``operator''>=&gt;</span> <span class=``number''>10</span><span class=``operator''>,</span> <span class=``string''>error_rate</span> <span class=``operator''>=&gt;</span> <span class=``number''>.001</span> <span class=``operator''>);</span> </pre> <pre> <span class=``variable''>$bf</span><span class=``operator''>-&gt;</span><span class=``variable''>add</span><span class=``operator''>(</span> <span class=``variable''>@keys</span> <span class=``operator''>);</span> </pre> <pre> <span class=``keyword''>while</span> <span class=``operator''>(</span> <span class=``operator''>&lt;&gt;</span> <span class=``operator''>)</span> <span class=``operator''>{</span> <span class=``keyword''>chomp</span><span class=``operator''>;</span> <span class=``keyword''>print</span> <span class=``string''>``Found </span><span class=''variable``>$_</span><span class=''string``>\n''</span> <span class=``keyword''>if</span> <span class=``variable''>$bf</span><span class=``operator''>-&gt;</span><span class=``variable''>check</span><span class=``operator''>(</span> <span class=``variable''>$_</span> <span class=``operator''>);</span> <span class=``operator''>}</span> </pre> <p> </p> <hr /> <h1><a name=``constructors''>CONSTRUCTOR/a</h1> <dl> <dt><strong><a name=``new_params'' class=``item''>new %PARAM/a</strong>

<dd> <p>Create a brand new instance. Allowable params are <a href=``#error_rate''><code>error_rate</code></a>, <a href=``#capacity''><code>capacity</code></a>.</p> </dd> </li> <dt><strong><a name=``init'' class=``item''>init</a></strong>

<dd> <p>Calculates the best number of hash functions and optimum filter length, creates some random salts, and generates a blank bit vector. Called automatically by constructor.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name=``accessors''>ACCESSOR/a</h1> <dl> <dt><strong><a name=``capacity'' class=``item''>capacity</a></strong>

<dd> <p>Returns the total capacity of the Bloom filter</p> </dd> </li> <dt><strong><a name=``error_rate'' class=``item''>error_rate</a></strong>

<dd> <p>Returns the configured maximum error rate</p> </dd> </li> <dt><strong><a name=``length'' class=``item''>length</a></strong>

<dd> <p>Returns the length of the Bloom filter in bits</p> </dd> </li> <dt><strong><a name=``key_count'' class=``item''>key_count</a></strong>

<dd> <p>Returns the number of items currently stored in the filter</p> </dd> </li> <dt><strong><a name=``on_bits'' class=``item''>on_bits</a></strong>

<dd> <p>Returns the number of 'on' bits in the filter</p> </dd> </li> <dt><strong><a name=``salts'' class=``item''>salts</a></strong>

<dd> <p>Returns the list of salts used to create the hash functions</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name=``public_methods''>PUBLIC METHOD/a</h1> <dl> <dt><strong><a name=``add_keys'' class=``item''>add @KEY/a</strong>

<dd> <p>Adds the list of keys to the filter. Will fail, return <a href=``../../../lib/pods/perlfunc.html#undef''><code>undef</code></a> and complain if the number of keys in the filter exceeds the configured capacity.</p> </dd> </li> <dt><strong><a name=``check_keys'' class=``item''>check @KEY/a</strong>

<dd> <p>Checks the provided key list against the Bloom filter, and returns a list of equivalent length, with true or false values depending on whether there was a match.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name=``internal_methods''>INTERNAL METHOD/a</h1> <dl> <dt><strong><a name=``calculate_shortest_filter_length_capacity_err_rate'' class=``item''>_calculate_shortest_filter_length CAPACITY ERR_RAT&_calculate_shortest_filter_length CAPACITY ERR_RAT;/a></strong>

<dd> <p>Given a desired error rate and maximum capacity, returns the optimum combination of vector length (in bits) and number of hash functions to use in building the filter, where &quot;optimum&quot; means shortest vector length.</p> </dd> </li> <dt><strong><a name=``_get_cells'' class=``item''>_get_cells KEY</a></strong>

<dd> <p>Given a key, hashes it using the list of salts and returns an array of cell indexes corresponding to the key.</p> </dd> </li> </dl> <p> </p> <hr /> <h1><a name=``author''>AUTHOR</a></h1> <p>Maciej Ceglowski &lt;<a href=``mailto:maciej@ceglowski.com''>maciej@ceglowski.com&gt;</p> <p> </p> <hr /> <h1><a name=``changelog''>CHANGELOG</a></h1> <p>Feb 2007 big speedup by Dmitriy Ryaboy &lt;<a href=``mailto:dmitriy.ryaboy@ask.com''>dmitriy.ryaboy@ask.com&gt; (thanks!)</p> <p> </p> <hr /> <h1><a name=``copyright_and_license''>COPYRIGHT AND LICENS©RIGHT AND LICENS;/a></h1> <p>(c) 2004 Maciej Ceglowski</p> <p>This is free software, distributed under version 2 of the GNU Public License (GPL).</p>

</body>

</html>

 /Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Bloom-Filter/blib/html/site/lib/Bloom/Filter.html