A simple Java library for Bloom Filters.
See the LICENSE.md for a copy of the BSD 2-clause license.
Grab the Jar from releases and add it to your classpath or buildpath.
Create a bloom filter by passing how many items you expect to be in the filter and a expected tolerance of false positives to occur.
BloomFilter filter = new BloomFilter(1000, 0.01);
You can add items to the filter by:
int ip = addr.getIpAddress();
filter.add(ip);
Later you can check if a key has been added to the filter:
if (filter.contains(ip)) {
if (expensiveQuery.contains(ip)) {
throw new Exception("IP is blacklisted");
}
}
Bugs are tracked on GitHub at https://github.com/krisives/jbloomer/issues
If you want to improve jbloomer fork krisives/jbloomer and make your changes then submit a pull request.