Class BloomFilter<T>
- Type Parameters:
T- the type of instances that theBloomFilteraccepts
- All Implemented Interfaces:
Predicate<T>,Serializable
T. 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 mightContain(Object) will erroneously return true for an object that
has not actually been put in the BloomFilter.
- Since:
- 11.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Equivalent tomightContain(T); provided only to satisfy thePredicateinterface.copy()Deprecated.Creates a newBloomFilterthat's a copy of this instance.static <T> BloomFilter<T> Deprecated.Creates aBloomFilterwith the expected number of insertions and a default expected false positive probability of 3%.static <T> BloomFilter<T> Deprecated.Creates aBloomFilterwith the expected number of insertions and expected false positive probability.booleanDeprecated.Indicates whether another object is equal to this predicate.doubleDeprecated.Returns the probability that mightContain(Object) will erroneously returntruefor an object that has not actually been put in theBloomFilter.inthashCode()Deprecated.booleanisCompatible(BloomFilter<T> that) Deprecated.Determines whether a given bloom filter is compatible with this bloom filter.booleanmightContain(T object) Deprecated.Returnstrueif the element might have been put in this Bloom filter,falseif this is definitely not the case.booleanDeprecated.Puts an element into thisBloomFilter.voidputAll(BloomFilter<T> that) Deprecated.Combines this bloom filter with another bloom filter by performing a bitwise OR of the underlying data.
-
Method Details
-
copy
Deprecated.Creates a newBloomFilterthat's a copy of this instance. The new instance is equal to this instance but shares no mutable state.- Since:
- 12.0
-
mightContain
Deprecated.Returnstrueif the element might have been put in this Bloom filter,falseif this is definitely not the case. -
apply
Deprecated.Equivalent tomightContain(T); provided only to satisfy thePredicateinterface. When using a reference of typeBloomFilter, always invokemightContain(T)directly instead. -
put
Deprecated.Puts an element into thisBloomFilter. Ensures that subsequent invocations ofmightContain(Object)with the same element will always returntrue.- Returns:
- true if the bloom filter's bits changed as a result of this operation. If the bits
changed, this is definitely the first time
objecthas been added to the filter. If the bits haven't changed, this might be the first timeobjecthas been added to the filter. Note thatput(t)always returns the opposite result to whatmightContain(t)would have returned at the time it is called." - Since:
- 12.0 (present in 11.0 with
voidreturn type})
-
expectedFpp
public double expectedFpp()Deprecated.Returns the probability that mightContain(Object) will erroneously returntruefor an object that has not actually been put in theBloomFilter.Ideally, this number should be close to the
fppparameter passed in create(Funnel, int, double), or smaller. If it is significantly higher, it is usually the case that too many elements (more than expected) have been put in theBloomFilter, degenerating it.- Since:
- 14.0 (since 11.0 as expectedFalsePositiveProbability())
-
isCompatible
Deprecated.Determines whether a given bloom filter is compatible with this bloom filter. For two bloom filters to be compatible, they must:- not be the same instance
- have the same number of hash functions
- have the same bit size
- have the same strategy
- have equal funnels
- Parameters:
that- The bloom filter to check for compatibility.- Since:
- 15.0
-
putAll
Deprecated.Combines this bloom filter with another bloom filter by performing a bitwise OR of the underlying data. The mutations happen to this instance. Callers must ensure the bloom filters are appropriately sized to avoid saturating them.- Parameters:
that- The bloom filter to combine this bloom filter with. It is not mutated.- Throws:
IllegalArgumentException- ifisCompatible(that) == false- Since:
- 15.0
-
equals
Deprecated.Description copied from interface:PredicateIndicates whether another object is equal to this predicate.Most implementations will have no reason to override the behavior of
Object.equals(java.lang.Object). However, an implementation may also choose to returntruewheneverobjectis aPredicatethat it considers interchangeable with this one. "Interchangeable" typically means thatthis.apply(t) == that.apply(t)for alltof typeT). Note that afalseresult from this method does not imply that the predicates are known not to be interchangeable. -
hashCode
public int hashCode()Deprecated. -
create
Deprecated.Creates aBloomFilterwith the expected number of insertions and expected false positive probability.Note that overflowing a
BloomFilterwith significantly more elements than specified, will result in its saturation, and a sharp deterioration of its false positive probability.The constructed
BloomFilter<T>will be serializable if the providedFunnel<T>is.It is recommended that the funnel be implemented as a Java enum. This has the benefit of ensuring proper serialization and deserialization, which is important since
equals(java.lang.Object)also relies on object identity of funnels.- Parameters:
funnel- the funnel of T's that the constructedBloomFilter<T>will useexpectedInsertions- the number of expected insertions to the constructedBloomFilter<T>; must be positivefpp- the desired false positive probability (must be positive and less than 1.0)- Returns:
- a
BloomFilter
-
create
Deprecated.Creates aBloomFilterwith the expected number of insertions and a default expected false positive probability of 3%.Note that overflowing a
BloomFilterwith significantly more elements than specified, will result in its saturation, and a sharp deterioration of its false positive probability.The constructed
BloomFilter<T>will be serializable if the providedFunnel<T>is.- Parameters:
funnel- the funnel of T's that the constructedBloomFilter<T>will useexpectedInsertions- the number of expected insertions to the constructedBloomFilter<T>; must be positive- Returns:
- a
BloomFilter
-