Class AdaptiveBlockSplitBloomFilter
- java.lang.Object
-
- org.apache.parquet.column.values.bloomfilter.AdaptiveBlockSplitBloomFilter
-
- All Implemented Interfaces:
BloomFilter
public class AdaptiveBlockSplitBloomFilter extends Object implements BloomFilter
The purpose of this is to finally generate a bloom filter with the optimal bit size according to the number of real data distinct values. `AdaptiveBlockSplitBloomFilter` contains multiple `BlockSplitBloomFilter` as candidates and inserts values in the candidates at the same time. Some candidates that are too small will be eliminated during the insertion process. Finally we will choose the most appropriate size candidate to write out.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAdaptiveBlockSplitBloomFilter.BloomFilterCandidate-
Nested classes/interfaces inherited from interface org.apache.parquet.column.values.bloomfilter.BloomFilter
BloomFilter.Algorithm, BloomFilter.Compression, BloomFilter.HashStrategy
-
-
Constructor Summary
Constructors Constructor Description AdaptiveBlockSplitBloomFilter(int maximumBytes, int numCandidates, double fpp, ColumnDescriptor column)AdaptiveBlockSplitBloomFilter(int maximumBytes, BloomFilter.HashStrategy hashStrategy, double fpp, int numCandidates, ColumnDescriptor column)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanfindHash(long hash)Determine whether an element is in set or not.BloomFilter.AlgorithmgetAlgorithm()Return the algorithm that the bloom filter apply.intgetBitsetSize()Get the number of bytes for bitset in this Bloom filter.protected List<AdaptiveBlockSplitBloomFilter.BloomFilterCandidate>getCandidates()BloomFilter.CompressiongetCompression()Return the compress algorithm that the bloom filter apply.BloomFilter.HashStrategygetHashStrategy()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.longhash(Object value)Compute hash for Object value by using its plain encoding result.longhash(Binary value)Compute hash for Binary value by using its plain encoding result.voidinsertHash(long hash)Insert an element to the multiple bloom filter candidates and remove the bad candidate if the number of distinct values exceeds its expected size.protected AdaptiveBlockSplitBloomFilter.BloomFilterCandidateoptimalCandidate()Used at the end of the insertion, select the candidate of the smallest size.voidwriteTo(OutputStream out)Write the Bloom filter to an output stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.parquet.column.values.bloomfilter.BloomFilter
canMergeFrom, equals, merge
-
-
-
-
Constructor Detail
-
AdaptiveBlockSplitBloomFilter
public AdaptiveBlockSplitBloomFilter(int maximumBytes, int numCandidates, double fpp, ColumnDescriptor column)- Parameters:
maximumBytes- the maximum bytes size of candidatenumCandidates- the number of candidatesfpp- the false positive probability
-
AdaptiveBlockSplitBloomFilter
public AdaptiveBlockSplitBloomFilter(int maximumBytes, BloomFilter.HashStrategy hashStrategy, double fpp, int numCandidates, ColumnDescriptor column)
-
-
Method Detail
-
optimalCandidate
protected AdaptiveBlockSplitBloomFilter.BloomFilterCandidate optimalCandidate()
Used at the end of the insertion, select the candidate of the smallest size. At least one of the largest candidates will be kept when inserting data.- Returns:
- the smallest and optimal candidate
-
getCandidates
protected List<AdaptiveBlockSplitBloomFilter.BloomFilterCandidate> getCandidates()
-
writeTo
public void writeTo(OutputStream out) throws IOException
Description copied from interface:BloomFilterWrite 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.- Specified by:
writeToin interfaceBloomFilter- Parameters:
out- the output stream to write- Throws:
IOException
-
insertHash
public void insertHash(long hash)
Insert an element to the multiple bloom filter candidates and remove the bad candidate if the number of distinct values exceeds its expected size.- Specified by:
insertHashin interfaceBloomFilter- Parameters:
hash- the hash result of element.
-
getBitsetSize
public int getBitsetSize()
Description copied from interface:BloomFilterGet the number of bytes for bitset in this Bloom filter.- Specified by:
getBitsetSizein interfaceBloomFilter- Returns:
- The number of bytes for bitset in this Bloom filter.
-
findHash
public boolean findHash(long hash)
Description copied from interface:BloomFilterDetermine whether an element is in set or not.- Specified by:
findHashin interfaceBloomFilter- 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.
-
hash
public long hash(Object value)
Description copied from interface:BloomFilterCompute hash for Object value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
getHashStrategy
public BloomFilter.HashStrategy getHashStrategy()
Description copied from interface:BloomFilterReturn the hash strategy that the bloom filter apply.- Specified by:
getHashStrategyin interfaceBloomFilter- Returns:
- hash strategy that the bloom filter apply
-
getAlgorithm
public BloomFilter.Algorithm getAlgorithm()
Description copied from interface:BloomFilterReturn the algorithm that the bloom filter apply.- Specified by:
getAlgorithmin interfaceBloomFilter- Returns:
- algorithm that the bloom filter apply
-
getCompression
public BloomFilter.Compression getCompression()
Description copied from interface:BloomFilterReturn the compress algorithm that the bloom filter apply.- Specified by:
getCompressionin interfaceBloomFilter- Returns:
- compress algorithm that the bloom filter apply
-
hash
public long hash(int value)
Description copied from interface:BloomFilterCompute hash for int value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
public long hash(long value)
Description copied from interface:BloomFilterCompute hash for long value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
public long hash(double value)
Description copied from interface:BloomFilterCompute hash for double value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
public long hash(float value)
Description copied from interface:BloomFilterCompute hash for float value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
hash
public long hash(Binary value)
Description copied from interface:BloomFilterCompute hash for Binary value by using its plain encoding result.- Specified by:
hashin interfaceBloomFilter- Parameters:
value- the value to hash- Returns:
- hash result
-
-