Class SparseBloomFilter
- All Implemented Interfaces:
BitMapProducer,BloomFilter,IndexProducer
- Since:
- 4.5
-
Field Summary
Fields inherited from interface org.apache.commons.collections4.bloomfilter.BloomFilter
SPARSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong[]Return a copy of the BitMapProducer data as a bit map array.intGets the cardinality (number of enabled bits) of this Bloom filter.intReturns the characteristics of the filter.voidclear()Resets the filter to its initial, unpopulated state.booleancontains(BitMapProducer bitMapProducer) Returnstrueif this filter contains the bits specified in the bit maps produced by the bitMapProducer.booleancontains(IndexProducer indexProducer) Returnstrueif this filter contains the indices specified IndexProducer.copy()Creates a new instance of the BloomFilter with the same properties as the current one.booleanforEachBitMap(LongPredicate consumer) Each bit map is passed to the predicate in order.booleanforEachIndex(IntPredicate consumer) Each index is passed to the predicate.getShape()Gets the shape that was used when the filter was built.booleanisEmpty()Determines if all the bits are off.booleanmerge(BitMapProducer bitMapProducer) Merges the specified hasher into this Bloom filter.booleanmerge(BloomFilter other) Merges the specified Bloom filter into this Bloom filter.booleanMerges the specified hasher into this Bloom filter.booleanmerge(IndexProducer indexProducer) Merges the specified IndexProducer into this Bloom filter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.bloomfilter.BitMapProducer
forEachBitMapPairMethods inherited from interface org.apache.commons.collections4.bloomfilter.BloomFilter
contains, contains, estimateIntersection, estimateN, estimateUnion, isFull, uniqueIndicesMethods inherited from interface org.apache.commons.collections4.bloomfilter.IndexProducer
asIndexArray
-
Constructor Details
-
SparseBloomFilter
Constructs an empty BitSetBloomFilter.- Parameters:
shape- The shape of the filter.
-
-
Method Details
-
asBitMapArray
Description copied from interface:BitMapProducerReturn a copy of the BitMapProducer data as a bit map array.The default implementation of this method is slow. It is recommended that implementing classes reimplement this method.
- Specified by:
asBitMapArrayin interfaceBitMapProducer- Returns:
- An array of bit map data.
-
cardinality
Description copied from interface:BloomFilterGets the cardinality (number of enabled bits) of this Bloom filter.This is also known as the Hamming value or Hamming number.
- Specified by:
cardinalityin interfaceBloomFilter- Returns:
- the cardinality of this filter
-
characteristics
Description copied from interface:BloomFilterReturns the characteristics of the filter.Characteristics are defined as bits within the characteristics integer.
- Specified by:
characteristicsin interfaceBloomFilter- Returns:
- the characteristics for this bloom filter.
-
clear
Description copied from interface:BloomFilterResets the filter to its initial, unpopulated state.- Specified by:
clearin interfaceBloomFilter
-
contains
Description copied from interface:BloomFilterReturnstrueif this filter contains the bits specified in the bit maps produced by the bitMapProducer.- Specified by:
containsin interfaceBloomFilter- Parameters:
bitMapProducer- theBitMapProducerto provide the bit maps.- Returns:
trueif this filter is enabled for all bits specified by the bit maps
-
contains
Description copied from interface:BloomFilterReturnstrueif this filter contains the indices specified IndexProducer.Specifically this returns
trueif this filter is enabled for all bit indexes identified by theIndexProducer.- Specified by:
containsin interfaceBloomFilter- Parameters:
indexProducer- the IndexProducer to provide the indexes- Returns:
trueif this filter is enabled for all bits specified by the IndexProducer
-
copy
Description copied from interface:BloomFilterCreates a new instance of the BloomFilter with the same properties as the current one.- Specified by:
copyin interfaceBloomFilter- Returns:
- a copy of this BloomFilter
-
forEachBitMap
Description copied from interface:BitMapProducerEach bit map is passed to the predicate in order. The predicate is applied to each bit map value, if the predicate returnsfalsethe execution is stopped,falseis returned, and no further bit maps are processed.If the producer is empty this method will return true.
Any exceptions thrown by the action are relayed to the caller.
- Specified by:
forEachBitMapin interfaceBitMapProducer- Parameters:
consumer- the function to execute- Returns:
trueif all bit maps returnedtrue,falseotherwise.
-
forEachIndex
Description copied from interface:IndexProducerEach index is passed to the predicate. The predicate is applied to each index value, if the predicate returnsfalsethe execution is stopped,falseis returned, and no further indices are processed.Any exceptions thrown by the action are relayed to the caller.
Indices ordering and uniqueness is not guaranteed.
- Specified by:
forEachIndexin interfaceIndexProducer- Parameters:
consumer- the action to be performed for each non-zero bit index.- Returns:
trueif all indexes return true from consumer,falseotherwise.
-
getShape
Description copied from interface:BloomFilterGets the shape that was used when the filter was built.- Specified by:
getShapein interfaceBloomFilter- Returns:
- The shape the filter was built with.
-
isEmpty
Description copied from interface:BloomFilterDetermines if all the bits are off. This is equivalent tocardinality() == 0.Note: This method is optimised for non-sparse filters. Implementers are encouraged to implement faster checks if possible.
- Specified by:
isEmptyin interfaceBloomFilter- Returns:
trueif no bits are enabled,falseotherwise.
-
merge
Description copied from interface:BloomFilterMerges the specified hasher into this Bloom filter. Specifically all bit indexes that are identified by theproducerwill be enabled in this filter.Note: This method should return
trueeven if no additional bit indexes were enabled. Afalseresult indicates that this filter may or may not contain all the indexes enabled in theproducer. This state may occur in complex Bloom filter implementations like counting Bloom filters.- Specified by:
mergein interfaceBloomFilter- Parameters:
bitMapProducer- The producer to merge.- Returns:
- true if the merge was successful
-
merge
Description copied from interface:BloomFilterMerges the specified Bloom filter into this Bloom filter.Specifically all bit indexes that are identified by the
otherwill be enabled in this filter.Note: This method should return
trueeven if no additional bit indexes were enabled. Afalseresult indicates that this filter may or may not contain theotherBloom filter. This state may occur in complex Bloom filter implementations like counting Bloom filters.- Specified by:
mergein interfaceBloomFilter- Parameters:
other- The bloom filter to merge into this one.- Returns:
- true if the merge was successful
-
merge
Description copied from interface:BloomFilterMerges the specified hasher into this Bloom filter. Specifically all bit indexes that are identified by thehasherwill be enabled in this filter.Note: This method should return
trueeven if no additional bit indexes were enabled. Afalseresult indicates that this filter may or may not contain thehashervalues. This state may occur in complex Bloom filter implementations like counting Bloom filters.- Specified by:
mergein interfaceBloomFilter- Parameters:
hasher- The hasher to merge.- Returns:
- true if the merge was successful
-
merge
Description copied from interface:BloomFilterMerges the specified IndexProducer into this Bloom filter. Specifically all bit indexes that are identified by theproducerwill be enabled in this filter.Note: This method should return
trueeven if no additional bit indexes were enabled. Afalseresult indicates that this filter may or may not contain all the indexes of theproducer. This state may occur in complex Bloom filter implementations like counting Bloom filters.- Specified by:
mergein interfaceBloomFilter- Parameters:
indexProducer- The IndexProducer to merge.- Returns:
- true if the merge was successful
-