@InterfaceAudience.Private public class BloomFilterChunk extends Object implements BloomFilterBase
CompoundBloomFilter
Modifier and Type | Field and Description |
---|---|
protected ByteBuffer |
bloom
Bloom bits
|
protected BloomType |
bloomType
The type of bloom
|
protected long |
byteSize
Bytes (B) in the array.
|
protected Hash |
hash
Hash Function
|
protected int |
hashCount
Number of hash functions
|
protected int |
hashType
Hash type
|
protected int |
keyCount
Keys currently in the bloom
|
protected int |
maxKeys
Max Keys expected for the bloom
|
Constructor and Description |
---|
BloomFilterChunk(DataInput meta)
Loads bloom filter meta data from file input.
|
BloomFilterChunk(int hashType,
BloomType bloomType) |
BloomFilterChunk(int maxKeys,
double errorRate,
int hashType,
int foldFactor)
Determines & initializes bloom filter meta data from user config.
|
Modifier and Type | Method and Description |
---|---|
double |
actualErrorRate()
Computes the error rate for this Bloom filter, taking into account the
actual number of hash functions and keys inserted.
|
(package private) void |
add(byte[] buf,
int offset,
int len) |
void |
add(Cell cell) |
void |
allocBloom() |
(package private) void |
bloomCheck(ByteBuffer bloom) |
void |
compactBloom() |
BloomFilterChunk |
createAnother()
Creates another similar Bloom filter.
|
(package private) static boolean |
get(int pos,
ByteBuffer bloomBuf,
int bloomOffset)
Check if bit at specified index is 1.
|
long |
getByteSize() |
int |
getHashCount() |
int |
getHashType() |
long |
getKeyCount() |
long |
getMaxKeys() |
(package private) void |
sanityCheck() |
(package private) void |
set(long pos)
Set the bit at the specified index to 1.
|
private void |
setHashLoc(int hash1,
int hash2) |
String |
toString() |
void |
writeBloom(DataOutput out)
Writes just the bloom filter to the output array
|
protected long byteSize
protected int hashCount
protected final int hashType
protected int keyCount
protected int maxKeys
protected ByteBuffer bloom
public BloomFilterChunk(DataInput meta) throws IOException, IllegalArgumentException
meta
- stored bloom meta dataIllegalArgumentException
- meta data is invalidIOException
public BloomFilterChunk(int hashType, BloomType bloomType)
public BloomFilterChunk(int maxKeys, double errorRate, int hashType, int foldFactor) throws IllegalArgumentException
allocBloom()
to allocate bloom filter data.maxKeys
- Maximum expected number of keys that will be stored in this
bloomerrorRate
- Desired false positive error rate. Lower rate = more
storage requiredhashType
- Type of hash function to usefoldFactor
- When finished adding entries, you may be able to 'fold'
this bloom to save space. Tradeoff potentially excess bytes in
bloom for ability to fold if keyCount is exponentially greater
than maxKeys.IllegalArgumentException
public double actualErrorRate()
public BloomFilterChunk createAnother()
public void allocBloom()
void sanityCheck() throws IllegalArgumentException
IllegalArgumentException
void bloomCheck(ByteBuffer bloom) throws IllegalArgumentException
IllegalArgumentException
void add(byte[] buf, int offset, int len)
private void setHashLoc(int hash1, int hash2)
void set(long pos)
pos
- index of bitstatic boolean get(int pos, ByteBuffer bloomBuf, int bloomOffset)
pos
- index of bitpublic long getKeyCount()
getKeyCount
in interface BloomFilterBase
public long getMaxKeys()
getMaxKeys
in interface BloomFilterBase
public long getByteSize()
getByteSize
in interface BloomFilterBase
public int getHashType()
public void compactBloom()
public void writeBloom(DataOutput out) throws IOException
out
- OutputStream to place bloomIOException
- Error writing bloom arraypublic int getHashCount()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.