Using Bloom Filters
Anyone who has used Perl for any length of time is familiar with the lookup hash, a handy idiom for doing existence tests:
foreach my $e ( @things ) { $lookup{$e}++ }
sub check {
my ( $key ) = @_;
print "Found $key!" if exists( $lookup{ $key } );
}
As useful as the lookup hash is, it can become unwieldy for very large lists or in cases where the keys themselves are large. When a lookup hash grows too big, the usual recourse is to move it to a database or flat file, perhaps keeping a local cache of the most frequently used keys to improve performance.
foreach my $e ( @things ) { $lookup{$e}++ }
sub check {
my ( $key ) = @_;
print "Found $key!" if exists( $lookup{ $key } );
}
As useful as the lookup hash is, it can become unwieldy for very large lists or in cases where the keys themselves are large. When a lookup hash grows too big, the usual recourse is to move it to a database or flat file, perhaps keeping a local cache of the most frequently used keys to improve performance.
Labels: Bloom Filters
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home