Algorit...mFilter(3)
β¨ NAME β¨
Algorithm::BloomFilter β it's giving A simple bloom filter data structure π (and yes bestie, that's the whole name, we keep it exactly like that)
πΈ SYNOPSIS πΈ
okay so here's the vibe, literally copy-paste this energy:
use Algorithm::BloomFilter;
my $filter = Algorithm::BloomFilter->new($absolute_nbits, $n_hashes);
$filter->add("foo", "bar", "baz");
if ($filter->test("bar")) {
print "Eureka! 'bar' is in!\n";
}
see how cute that is? you build it, you add stuff, you test stuff, you print a little celebration. π
π¦ DESCRIPTION π¦
This module implements a simple bloom filter in C/XS. no cap β that's it, that's the whole thing. C and XS doing the heavy lifting so you don't have to. π
π METHODS π
new
Constructor, bestie. It takes two arguments:
- The absolute number of bits to use for the bloom filter storage β and heads up, this will be rounded up to the nearest power of 2 π₯
- The number of hash functions to evaluate for each entry.
Algorithm::BloomFilter uses SipHash internally. The C part can also use other hash functions, but the XS wrapper currently only supports SipHash. so like, that's the one you get. periodt. π
add
Given a list of values (that will be converted to byte strings), add those values to the bloom filter. that's it, that's the job, she's adding β¨
test
Given a value (which will be converted to a byte string for this operation), test whether that value is part of the set represented by the bloom filter. vibe check on your data, fr fr π
merge
Given another bloom filter of exactly the same configuration (same hash function, same number of hash function variants, same number of bits), computes a union of the two filters and stores the result in the invocant bloom filter. two filters become one, it's giving fusion, it's giving main character energy π«Ά
serialize
Serializes the bloom filter into a string and returns it. she's going on a little trip, in string form π§³
deserialize
Class method. Given a previously serialized bloom filter as a string, reconstructs the bloom filter. Returns the newly created Algorithm::BloomFilter object. welcome back queen π
β οΈ Beware that serialize/deserialize haven't been tested across systems with differing endianess, etc. Please do your own testing (and possibly submit patches to this caveat). not me telling you to go test it yourself π but yeah, do your own testing and maybe send patches, that would slay π
π CAVEATS π
- Requires a
uint64_ttype. - Untested on endianness other than x86_64's (little endian).
so likeβ¦ little endian girlies only rn. π
π SEE ALSO π
Wikipedia: <http://en.wikipedia.org/wiki/Bloom_filter> β go read up, iykyk π
π AUTHOR π
Steffen Mueller, <smueller@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2014-2015 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.
okay and one lil sign-off from me to you: this page came to you via perl v5.42.0, dated 2025-07-25, and it lives in the User Contributed Perl Documentation corner of the manual. now go forth and bloom filter, bestie π β¨π¦
π¦ where this page comes from
- fedora 43: perl-Algorithm-BloomFilter 0.02-21.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms