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
Nested ClassesModifier and TypeClassDescriptionprivate classprivate static classA Bloom filter chunk enqueued for writing -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate HFileBlockIndex.BlockIndexWriterprivate BloomTypeprivate booleanWhether to cache-on-write compound Bloom filter chunksprivate BloomFilterChunkThe current chunk being written toprivate intThe size of individual Bloom filter chunks to createprivate byte[]The first key in the current Bloom filter chunk.private static final org.slf4j.Loggerprivate intMaximum fold factorprivate CellThe prev Cell that was processedprivate BloomFilterChunkPrevious 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
ConstructorsConstructorDescriptionCompoundBloomFilterWriter(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 voidvoidAppend the given cellvoidThe action that needs to be performed beforeShipper.shipped()is performedvoidblockWritten(long offset, int onDiskSize, int uncompressedSize) Called after a block has been written, and its offset, raw size, and compressed size have been determined.voidCompact the Bloom filter before writing metadata & data to disk.private voidenqueueReadyChunk(boolean closing) Enqueue the current chunk if it is ready to be written out.booleanReturns true if inline blocks produced by this writer should be cachedorg.apache.hadoop.io.WritableGet a writable interface into bloom filter data (the actual Bloom bits).The type of blocks this block writer produces.org.apache.hadoop.io.WritableGet a writable interface into bloom filter meta data.Returns the previous cell written by this writerbooleanshouldWriteBlock(boolean closing) Determines whether there is a new block to be written out.voidWrites the block to the provided stream.Methods inherited from class org.apache.hadoop.hbase.io.hfile.CompoundBloomFilterBase
getByteSize, getKeyCount, getMaxKeysMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:InlineBlockWriterDetermines 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:
shouldWriteBlockin 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:CellSinkAppend the given cell- Specified by:
appendin interfaceCellSink- Parameters:
cell- the cell to be added- Throws:
IOException
-
beforeShipped
Description copied from interface:ShipperListenerThe action that needs to be performed beforeShipper.shipped()is performed- Specified by:
beforeShippedin interfaceShipperListener- Throws:
IOException
-
getPrevCell
Description copied from interface:BloomFilterWriterReturns the previous cell written by this writer- Specified by:
getPrevCellin interfaceBloomFilterWriter- Returns:
- the previous cell
-
allocateNewChunk
-
writeInlineBlock
Description copied from interface:InlineBlockWriterWrites 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:
writeInlineBlockin interfaceInlineBlockWriter- Throws:
IOException
-
blockWritten
Description copied from interface:InlineBlockWriterCalled 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:
blockWrittenin 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:InlineBlockWriterThe type of blocks this block writer produces.- Specified by:
getInlineBlockTypein interfaceInlineBlockWriter
-
compactBloom
Description copied from interface:BloomFilterWriterCompact the Bloom filter before writing metadata & data to disk.- Specified by:
compactBloomin interfaceBloomFilterWriter
-
getMetaWriter
Description copied from interface:BloomFilterWriterGet a writable interface into bloom filter meta data.- Specified by:
getMetaWriterin interfaceBloomFilterWriter- Returns:
- a writable instance that can be later written to a stream
-
getDataWriter
Description copied from interface:BloomFilterWriterGet a writable interface into bloom filter data (the actual Bloom bits). Not used for compound Bloom filters.- Specified by:
getDataWriterin interfaceBloomFilterWriter- Returns:
- a writable instance that can be later written to a stream
-
getCacheOnWrite
Description copied from interface:InlineBlockWriterReturns true if inline blocks produced by this writer should be cached- Specified by:
getCacheOnWritein interfaceInlineBlockWriter
-