Skip to content

krisives/jbloomer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

jbloomer

A simple Java library for Bloom Filters.

License

See the LICENSE.md for a copy of the BSD 2-clause license.

Download

Grab the Jar from releases and add it to your classpath or buildpath.

Usage

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

Bugs are tracked on GitHub at https://github.com/krisives/jbloomer/issues

Contributing

If you want to improve jbloomer fork krisives/jbloomer and make your changes then submit a pull request.