Class ConcurrentRollingBloomFilter<T>
- All Implemented Interfaces:
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
Modifier and TypeMethodDescriptionvoidAdds the specified element to this set if it is not already possibly present.voidaddAll(Collection<? extends T> elements) Adds all of the specified elements to this set if they are not possibly already present.Gets a snapshot of the current statistics of the set.booleanmightContain(T element) Checks if the given element might be a member of this set.toString()
-
Method Details
-
add
Description copied from interface:BloomFilterAdds 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 returntruefor the same object.- Specified by:
addin interfaceBloomFilter<T>- Parameters:
element- the element to add to this set.
-
addAll
Description copied from interface:BloomFilterAdds all of the specified elements to this set if they are not possibly already present.- Specified by:
addAllin interfaceBloomFilter<T>- Parameters:
elements- the elements to add to the set.
-
mightContain
Description copied from interface:BloomFilterChecks 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 istruethen the object may or may not be a member of this set, with a certain probability of false positives.- Specified by:
mightContainin interfaceBloomFilter<T>- Parameters:
element- the element to check for membership in this set.- Returns:
falseif the element is definitely not in the set, ortrueif it might be.
-
getStatistics
Description copied from interface:BloomFilterGets a snapshot of the current statistics of the set.- Specified by:
getStatisticsin interfaceBloomFilter<T>
-
toString
-