BloomFilter

public final class BloomFilter<E> implements ProbabilisticFilter<E>, Serializable

A Bloom filter for instances of E that implements the ProbabilisticFilter interface.

This implementation is backed by Google Guava's BloomFilter.

From Guava:

A Bloom filter offers an approximate containment test with one-sided error: if it claims that an element is contained in it, this might be in error, but if it claims that an element is not contained in it, then this is definitely true.

If you are unfamiliar with Bloom filters, this nice tutorial may help you understand how they work.

The false positive probability (FPP) of a bloom filter is defined as the probability that contains will erroneously return true for an object that has not actually been put in the BloomFilter.

Author

Brian Dupras

Guava Authors (underlying BloomFilter implementation)

Parameters

<E>

the type of instances that the BloomFilter accepts.

See also

<a target="guavadoc" href="http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/hash/BloomFilter.html">com.google.common.hash.BloomFilter</a>

Functions

Link copied to clipboard
public boolean add(@NotNull() @NotNull() E e)
Adds the specified element to this filter.
Link copied to clipboard
public boolean addAll(@NotNull() @NotNull() Collection<? extends E> c)
Adds all of the elements in the specified collection to this filter.
public boolean addAll(@NotNull() @NotNull() ProbabilisticFilter<E> f)
Combines this filter with another compatible filter.
Link copied to clipboard
public long capacity()
Returns the number of elements this filter can represent at its requested FPP.
Link copied to clipboard
public void clear()
Removes all of the elements from this filter.
Link copied to clipboard
public boolean contains(E e)
Returns true if this filter might contain the specified element, false if this is definitely not the case.
Link copied to clipboard
public boolean containsAll(@NotNull() @NotNull() Collection<? extends E> c)
Returns true if this filter might contain all of the elements of the specified collection (optional operation).
public boolean containsAll(ProbabilisticFilter<E> f)
Not supported.
Link copied to clipboard
public static BloomFilter<T> copyOf<T>(BloomFilter<T> f)
Creates a new BloomFilter that's a copy of this instance.
Link copied to clipboard
public static BloomFilter<T> create<T>(Funnel<T> funnel, long capacity)
Creates a BloomFilter with the expected number of insertions and a default expected false positive probability of 3%.
public static BloomFilter<T> create<T>(Funnel<T> funnel, long capacity, double fpp)
Creates a BloomFilter with the expected number of insertions and expected false positive probability.
Link copied to clipboard
public double currentFpp()
Returns the current false positive probability (FPP) of this filter.
Link copied to clipboard
public boolean equals(@Nullable() Object object)
Link copied to clipboard
public double fpp()
Returns the intended FPP limit of this filter.
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public boolean isCompatible(@NotNull() @NotNull() ProbabilisticFilter<E> f)
Returns true if the specified filter is compatible with this filter.
Link copied to clipboard
public boolean isEmpty()
Returns true if this filter contains no elements.
Link copied to clipboard
public boolean remove(E e)
Not supported.
Link copied to clipboard
public boolean removeAll(Collection<? extends E> c)
public boolean removeAll(ProbabilisticFilter<E> f)
Not supported.
Link copied to clipboard
public long size()
Returns the number of elements contained in this filter (its cardinality).
Link copied to clipboard
public long sizeLong()
Returns the number of elements contained in this filter (its cardinality).