Class ConcurrentRollingBloomFilter<T>
- java.lang.Object
-
- org.forgerock.bloomfilter.ConcurrentRollingBloomFilter<T>
-
- All Implemented Interfaces:
BloomFilter<T>
@ThreadSafe public final class ConcurrentRollingBloomFilter<T> extends Object implements BloomFilter<T>
A thread-safe implementation of a Bloom Filter that can expand over time to accommodate arbitrary numbers of elements, while also allowing old elements to be deleted after they have expired. Rolling bloom filters are useful for maintaining on-going blacklists of short-lived elements.
This implementation is optimised for concurrent read performance. Concurrent writes performance is likely to be considerably slower than reads, so this implementation is only suitable for situations where read performance is critical and writes are relatively rare. Write performance may be improved by batching writes via the
addAll(Collection)
method, or by using some external synchronisation mechanism to perform pre-emptive locking (at the cost of reducing read performance).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T element)
Adds the specified element to this set if it is not already possibly present.void
addAll(Collection<? extends T> elements)
Adds all of the specified elements to this set if they are not possibly already present.BloomFilterStatistics
getStatistics()
Gets a snapshot of the current statistics of the set.boolean
mightContain(T element)
Checks if the given element might be a member of this set.String
toString()
-
-
-
Method Detail
-
add
public void add(T element)
Description copied from interface:BloomFilter
Adds the specified element to this set if it is not already possibly present. After a call to this method, subsequent calls toBloomFilter.mightContain(Object)
will returntrue
for the same object.- Specified by:
add
in interfaceBloomFilter<T>
- Parameters:
element
- the element to add to this set.
-
addAll
public void addAll(Collection<? extends T> elements)
Description copied from interface:BloomFilter
Adds all of the specified elements to this set if they are not possibly already present.- Specified by:
addAll
in interfaceBloomFilter<T>
- Parameters:
elements
- the elements to add to the set.
-
mightContain
public boolean mightContain(T element)
Description copied from interface:BloomFilter
Checks if the given element might be a member of this set. If this method returnsfalse
, then the given object is definitely not a member of the set. If the result istrue
then the object may or may not be a member of this set, with a certain probability of false positives.- Specified by:
mightContain
in interfaceBloomFilter<T>
- Parameters:
element
- the element to check for membership in this set.- Returns:
false
if the element is definitely not in the set, ortrue
if it might be.
-
getStatistics
public BloomFilterStatistics getStatistics()
Description copied from interface:BloomFilter
Gets a snapshot of the current statistics of the set.- Specified by:
getStatistics
in interfaceBloomFilter<T>
-
-