CuckooFilter

@Beta()
public final class CuckooFilter<E> implements ProbabilisticFilter<E>, Serializable

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

"Cuckoo filters can replace Bloom filters for approximate set membership tests. Cuckoo filters support adding and removing items dynamically while achieving even higher performance than Bloom filters. For applications that store many items and target moderately low false positive rates, cuckoo filters have lower space overhead than space-optimized Bloom filters. Cuckoo filters outperform previous data structures that extend Bloom filters to support deletions substantially in both time and space." - Fan, et. al.

Cuckoo filters offer constant time performance for the basic operations add, remove, contains and sizeLong.

This class does not permit null elements.

Cuckoo filters implement the Serializable interface. They also support a more compact serial representation via the writeTo and readFrom methods. Both serialized forms will continue to be supported by future versions of this library. However, serial forms generated by newer versions of the code may not be readable by older versions of the code (e.g., a serialized cuckoo filter generated today may not be readable by a binary that was compiled 6 months ago).

ref: Cuckoo Filter: Practically Better Than Bloom Bin Fan, David G. Andersen, Michael Kaminsky†, Michael D. Mitzenmacher‡ Carnegie Mellon University, †Intel Labs, ‡Harvard University

Author

Brian Dupras

Alex Beal

Parameters

<E>

the type of elements that this filter accepts

See also

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(@NotNull() @NotNull() 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.
public boolean containsAll(@NotNull() @NotNull() ProbabilisticFilter<E> f)
Returns true if this filter might contain all elements contained in the specified filter.
Link copied to clipboard
public CuckooFilter<E> copy()
Returns a new CuckooFilter that's a copy of this instance.
Link copied to clipboard
public static CuckooFilter<T> create<T>(Funnel<? super T> funnel, long capacity)
Creates a filter with the expected number of insertions and a default expected false positive probability of 3.2%.
public static CuckooFilter<T> create<T>(Funnel<? super T> funnel, long capacity, double fpp)
Creates a filter 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 approximate 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 f 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 static CuckooFilter<T> readFrom<T>(InputStream in, Funnel<T> funnel)
Reads a byte stream, which was written by writeTo, into a .
Link copied to clipboard
public boolean remove(@NotNull() @NotNull() E e)
Removes the specified element from this filter.
Link copied to clipboard
public boolean removeAll(@NotNull() @NotNull() Collection<? extends E> c)
Removes from this filter all of its elements that are contained in the specified collection.
public boolean removeAll(@NotNull() @NotNull() ProbabilisticFilter<E> f)
Subtracts the specified filter from this filter.
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).
Link copied to clipboard
public String toString()
Link copied to clipboard
public void writeTo(OutputStream out)
Writes this cuckoo filter to an output stream, with a custom format (not Java serialization).