1Algorithm::BloomFilter(U3s)er Contributed Perl DocumentatAilognorithm::BloomFilter(3)
2
3
4
6 Algorithm::BloomFilter - A simple bloom filter data structure
7
9 use Algorithm::BloomFilter;
10
11 my $filter = Algorithm::BloomFilter->new($absolute_nbits, $n_hashes);
12
13 $filter->add("foo", "bar", "baz");
14 if ($filter->test("bar")) {
15 print "Eureka! 'bar' is in!\n";
16 }
17
19 This module implements a simple bloom filter in C/XS.
20
22 new
23 Constructor, takes two arguments: The absolute number of bits to use
24 for the bloom filter storage (this will be rounded up to the nearest
25 power of 2) and the number of hash functions to evaluate for each
26 entry.
27
28 "Algorithm::BloomFilter" uses SipHash internally. The C part can also
29 use other hash functions, but the XS wrapper currently only supports
30 SipHash.
31
32 add
33 Given a list of values (that will be converted to byte strings), add
34 those values to the bloom filter.
35
36 test
37 Given a value (which will be converted to a byte string for this
38 operation), test whether that value is part of the set represented by
39 the bloom filter.
40
41 merge
42 Given another bloom filter of exactly the same configuration (same hash
43 function, same number of hash function variants, same number of bits),
44 computes a union of the two filters and stores the result in the
45 invocant bloom filter.
46
47 serialize
48 Serializes the bloom filter into a string and returns it.
49
50 deserialize
51 Class method. Given a previously serialized bloom filter as a string,
52 reconstructs the bloom filter. Returns the newly created
53 "Algorithm::BloomFilter" object.
54
55 Beware that serialize/deserialize haven't been tested across systems
56 with differing endianess, etc. Please do your own testing (and possibly
57 submit patches to this caveat).
58
60 Requires a "uint64_t" type. Untested on endianness other than x86_64's
61 (little endian).
62
64 Wikipedia: <http://en.wikipedia.org/wiki/Bloom_filter>
65
67 Steffen Mueller, <smueller@cpan.org>
68
70 Copyright (C) 2014-2015 by Steffen Mueller
71
72 This library is free software; you can redistribute it and/or modify it
73 under the same terms as Perl itself, either Perl version 5.8.0 or, at
74 your option, any later version of Perl 5 you may have available.
75
76
77
78perl v5.30.1 2020-01-29 Algorithm::BloomFilter(3)