Interface BloomFilter
- All Known Implementing Classes:
AdaptiveBlockSplitBloomFilter,BlockSplitBloomFilter
public interface BloomFilter
A Bloom filter is a compact structure to indicate whether an item is not in a set or probably
in a set. The Bloom filter usually consists of a bit set that represents a elements set,
a hash strategy and a Bloom filter algorithm.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanMergeFrom(BloomFilter otherBloomFilter) Determines whether a given Bloom filter can be merged into this Bloom filter.booleanCompare this Bloom filter to the specified object.booleanfindHash(long hash) Determine whether an element is in set or not.Return the algorithm that the bloom filter apply.intGet the number of bytes for bitset in this Bloom filter.Return the compress algorithm that the bloom filter apply.Return the hash strategy that the bloom filter apply.longhash(double value) Compute hash for double value by using its plain encoding result.longhash(float value) Compute hash for float value by using its plain encoding result.longhash(int value) Compute hash for int value by using its plain encoding result.longhash(long value) Compute hash for long value by using its plain encoding result.longCompute hash for Object value by using its plain encoding result.longCompute hash for Binary value by using its plain encoding result.voidinsertHash(long hash) Insert an element to the Bloom filter, the element content is represented by the hash value of its plain encoding result.default voidmerge(BloomFilter otherBloomFilter) Merges this Bloom filter with another Bloom filter by performing a bitwise OR of the underlying bitsetsvoidwriteTo(OutputStream out) Write the Bloom filter to an output stream.
-
Method Details
-
writeTo
Write the Bloom filter to an output stream. It writes the Bloom filter header including the bitset's length in bytes, the hash strategy, the algorithm, and the bitset.- Parameters:
out- the output stream to write- Throws:
IOException
-
insertHash
void insertHash(long hash) Insert an element to the Bloom filter, the element content is represented by the hash value of its plain encoding result.- Parameters:
hash- the hash result of element.
-
findHash
boolean findHash(long hash) Determine whether an element is in set or not.- Parameters:
hash- the hash value of element plain encoding result.- Returns:
- false if element is must not in set, true if element probably in set.
-
getBitsetSize
int getBitsetSize()Get the number of bytes for bitset in this Bloom filter.- Returns:
- The number of bytes for bitset in this Bloom filter.
-
equals
Compare this Bloom filter to the specified object. -
hash
long hash(int value) Compute hash for int value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
long hash(long value) Compute hash for long value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
long hash(double value) Compute hash for double value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
long hash(float value) Compute hash for float value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
Compute hash for Binary value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
Compute hash for Object value by using its plain encoding result.- Parameters:
value- the value to hash- Returns:
- hash result
-
getHashStrategy
BloomFilter.HashStrategy getHashStrategy()Return the hash strategy that the bloom filter apply.- Returns:
- hash strategy that the bloom filter apply
-
getAlgorithm
BloomFilter.Algorithm getAlgorithm()Return the algorithm that the bloom filter apply.- Returns:
- algorithm that the bloom filter apply
-
getCompression
BloomFilter.Compression getCompression()Return the compress algorithm that the bloom filter apply.- Returns:
- compress algorithm that the bloom filter apply
-
canMergeFrom
Determines whether a given Bloom filter can be merged into this Bloom filter. For two Bloom filters to merge, they must:- have the same bit size
- have the same algorithm
- have the same hash strategy
- Parameters:
otherBloomFilter- The Bloom filter to merge this Bloom filter with.
-
merge
Merges this Bloom filter with another Bloom filter by performing a bitwise OR of the underlying bitsets- Parameters:
otherBloomFilter- The Bloom filter to merge this Bloom filter with.- Throws:
IOException
-