Package org.apache.hadoop.hbase.io.hfile
Class CompoundBloomFilterWriter
java.lang.Object
org.apache.hadoop.hbase.io.hfile.CompoundBloomFilterBase
org.apache.hadoop.hbase.io.hfile.CompoundBloomFilterWriter
- All Implemented Interfaces:
InlineBlockWriter
,CellSink
,ShipperListener
,BloomFilterBase
,BloomFilterWriter
@Private
public class CompoundBloomFilterWriter
extends CompoundBloomFilterBase
implements BloomFilterWriter, InlineBlockWriter
Adds methods required for writing a compound Bloom filter to the data section of an
HFile
to the CompoundBloomFilter
class.-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
private static class
A Bloom filter chunk enqueued for writing -
Field Summary
Modifier and TypeFieldDescriptionprivate HFileBlockIndex.BlockIndexWriter
private BloomType
private boolean
Whether to cache-on-write compound Bloom filter chunksprivate BloomFilterChunk
The current chunk being written toprivate int
The size of individual Bloom filter chunks to createprivate byte[]
The first key in the current Bloom filter chunk.private static final org.slf4j.Logger
private int
Maximum fold factorprivate ExtendedCell
The prev Cell that was processedprivate BloomFilterChunk
Previous chunk, so that we can create another similar chunkFields inherited from class org.apache.hadoop.hbase.io.hfile.CompoundBloomFilterBase
comparator, errorRate, hashType, numChunks, totalByteSize, totalKeyCount, totalMaxKeys, VERSION
-
Constructor Summary
ConstructorDescriptionCompoundBloomFilterWriter
(int chunkByteSizeHint, float errorRate, int hashType, int maxFold, boolean cacheOnWrite, CellComparator comparator, BloomType bloomType) each chunk's size in bytes. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
append
(ExtendedCell cell) Append the given cellvoid
The action that needs to be performed beforeShipper.shipped()
is performedvoid
blockWritten
(long offset, int onDiskSize, int uncompressedSize) Called after a block has been written, and its offset, raw size, and compressed size have been determined.void
Compact the Bloom filter before writing metadata & data to disk.private void
enqueueReadyChunk
(boolean closing) Enqueue the current chunk if it is ready to be written out.boolean
Returns true if inline blocks produced by this writer should be cachedorg.apache.hadoop.io.Writable
Get a writable interface into bloom filter data (the actual Bloom bits).The type of blocks this block writer produces.org.apache.hadoop.io.Writable
Get a writable interface into bloom filter meta data.Returns the previous cell written by this writerboolean
shouldWriteBlock
(boolean closing) Determines whether there is a new block to be written out.void
Writes the block to the provided stream.Methods inherited from class org.apache.hadoop.hbase.io.hfile.CompoundBloomFilterBase
getByteSize, getKeyCount, getMaxKeys
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.util.BloomFilterBase
getByteSize, getKeyCount, getMaxKeys
-
Field Details
-
LOG
-
chunk
The current chunk being written to -
prevChunk
Previous chunk, so that we can create another similar chunk -
maxFold
Maximum fold factor -
chunkByteSize
The size of individual Bloom filter chunks to create -
prevCell
The prev Cell that was processed -
readyChunks
-
firstKeyInChunk
The first key in the current Bloom filter chunk. -
bloomBlockIndexWriter
-
cacheOnWrite
Whether to cache-on-write compound Bloom filter chunks -
bloomType
-
-
Constructor Details
-
CompoundBloomFilterWriter
public CompoundBloomFilterWriter(int chunkByteSizeHint, float errorRate, int hashType, int maxFold, boolean cacheOnWrite, CellComparator comparator, BloomType bloomType) each chunk's size in bytes. The real chunk size might be different as required by the fold factor. target false positive rate hash function type to use maximum degree of folding allowed the bloom type
-
-
Method Details
-
shouldWriteBlock
Description copied from interface:InlineBlockWriter
Determines whether there is a new block to be written out. whether the file is being closed, in which case we need to write out all available data and not wait to accumulate another block- Specified by:
shouldWriteBlock
in interfaceInlineBlockWriter
-
enqueueReadyChunk
Enqueue the current chunk if it is ready to be written out.- Parameters:
closing
- true if we are closing the file, so we do not expect new keys to show up
-
append
Description copied from interface:CellSink
Append the given cell- Specified by:
append
in interfaceCellSink
- Parameters:
cell
- the cell to be added- Throws:
IOException
-
beforeShipped
Description copied from interface:ShipperListener
The action that needs to be performed beforeShipper.shipped()
is performed- Specified by:
beforeShipped
in interfaceShipperListener
- Throws:
IOException
-
getPrevCell
Description copied from interface:BloomFilterWriter
Returns the previous cell written by this writer- Specified by:
getPrevCell
in interfaceBloomFilterWriter
- Returns:
- the previous cell
-
allocateNewChunk
-
writeInlineBlock
Description copied from interface:InlineBlockWriter
Writes the block to the provided stream. Must not write any magic records. Called only ifInlineBlockWriter.shouldWriteBlock(boolean)
returned true. a stream (usually a compressing stream) to write the block to- Specified by:
writeInlineBlock
in interfaceInlineBlockWriter
- Throws:
IOException
-
blockWritten
Description copied from interface:InlineBlockWriter
Called after a block has been written, and its offset, raw size, and compressed size have been determined. Can be used to add an entry to a block index. If this type of inline blocks needs a block index, the inline block writer is responsible for maintaining it.- Specified by:
blockWritten
in interfaceInlineBlockWriter
- Parameters:
offset
- the offset of the block in the streamonDiskSize
- the on-disk size of the blockuncompressedSize
- the uncompressed size of the block
-
getInlineBlockType
Description copied from interface:InlineBlockWriter
The type of blocks this block writer produces.- Specified by:
getInlineBlockType
in interfaceInlineBlockWriter
-
compactBloom
Description copied from interface:BloomFilterWriter
Compact the Bloom filter before writing metadata & data to disk.- Specified by:
compactBloom
in interfaceBloomFilterWriter
-
getMetaWriter
Description copied from interface:BloomFilterWriter
Get a writable interface into bloom filter meta data.- Specified by:
getMetaWriter
in interfaceBloomFilterWriter
- Returns:
- a writable instance that can be later written to a stream
-
getDataWriter
Description copied from interface:BloomFilterWriter
Get a writable interface into bloom filter data (the actual Bloom bits). Not used for compound Bloom filters.- Specified by:
getDataWriter
in interfaceBloomFilterWriter
- Returns:
- a writable instance that can be later written to a stream
-
getCacheOnWrite
Description copied from interface:InlineBlockWriter
Returns true if inline blocks produced by this writer should be cached- Specified by:
getCacheOnWrite
in interfaceInlineBlockWriter
-