Package org.infinispan.commons.util
Class BloomFilter<E>
java.lang.Object
org.infinispan.commons.util.BloomFilter<E>
- Direct Known Subclasses:
MurmurHash3BloomFilter
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddToFilter(E value) Adds a value to the filter setting up to a number of bits equal to the number of hash functions.static <E> BloomFilter<E>createConcurrentFilter(int bitsToUse, Iterable<ToIntFunction<? super E>> hashFunctions) Same ascreateFilter(int, Iterable)except the returned {code BloomFilter} instance may be used concurrently without additional synchronization.static <E> BloomFilter<E>createFilter(int bitsToUse, Iterable<ToIntFunction<? super E>> hashFunctions) booleanpossiblyPresent(E value) Returnstrueif the element might be present,falseif the value was for sure not present.voidClears all current bits and sets them to the values in the providedIntSet.toString()
-
Method Details
-
createFilter
public static <E> BloomFilter<E> createFilter(int bitsToUse, Iterable<ToIntFunction<? super E>> hashFunctions) -
createConcurrentFilter
public static <E> BloomFilter<E> createConcurrentFilter(int bitsToUse, Iterable<ToIntFunction<? super E>> hashFunctions) Same ascreateFilter(int, Iterable)except the returned {code BloomFilter} instance may be used concurrently without additional synchronization.The provided function iterable must be able to be iterated upon concurrently.
- Type Parameters:
E-- Parameters:
bitsToUse-hashFunctions-- Returns:
-
addToFilter
Adds a value to the filter setting up to a number of bits equal to the number of hash functions. This method will also return {code true} if any of the bits were updated, meaning this value was for sure not present before.- Parameters:
value- the value to add to the filter- Returns:
- whether the filter was actually updated
-
possiblyPresent
Returnstrueif the element might be present,falseif the value was for sure not present.- Parameters:
value- the value to check for- Returns:
- whether this value may be present or for sure not
-
setBits
Clears all current bits and sets them to the values in the providedIntSet. Since this method clears and sets the values any other concurrent operations may be ignored.- Parameters:
intSet-
-
getIntSet
-
toString
-