Package org.apache.hadoop.hbase.io.hfile
Class PreviousBlockCompressionRatePredicator
java.lang.Object
org.apache.hadoop.hbase.io.hfile.PreviousBlockCompressionRatePredicator
- All Implemented Interfaces:
BlockCompressedSizePredicator
@Private
public class PreviousBlockCompressionRatePredicator
extends Object
implements BlockCompressedSizePredicator
This BlockCompressedSizePredicator implementation adjusts the block size limit based on the
compression rate of the block contents read so far. For the first block, adjusted size would be
zero, so it performs a compression of current block contents and calculate compression rate and
adjusted size. For subsequent blocks, decision whether the block should be finished or not will
be based on the compression rate calculated for the previous block.
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private int
private int
Fields inherited from interface org.apache.hadoop.hbase.io.hfile.BlockCompressedSizePredicator
BLOCK_COMPRESSED_SIZE_PREDICATOR, MAX_BLOCK_SIZE_UNCOMPRESSED
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
shouldFinishBlock
(int uncompressed) Returns true if the passed uncompressed size is larger than the limit calculated byupdateLatestBlockSizes
.void
updateLatestBlockSizes
(HFileContext context, int uncompressed, int compressed) Recalculates compression rate for the last block and adjusts the block size limit as: BLOCK_SIZE * (uncompressed/compressed).
-
Field Details
-
adjustedBlockSize
-
compressionRatio
-
configuredMaxBlockSize
-
-
Constructor Details
-
PreviousBlockCompressionRatePredicator
-
-
Method Details
-
updateLatestBlockSizes
Recalculates compression rate for the last block and adjusts the block size limit as: BLOCK_SIZE * (uncompressed/compressed).- Specified by:
updateLatestBlockSizes
in interfaceBlockCompressedSizePredicator
- Parameters:
context
- HFIleContext containing the configured max block size.uncompressed
- the uncompressed size of last block written.compressed
- the compressed size of last block written.
-
shouldFinishBlock
Returns true if the passed uncompressed size is larger than the limit calculated byupdateLatestBlockSizes
.- Specified by:
shouldFinishBlock
in interfaceBlockCompressedSizePredicator
- Parameters:
uncompressed
- true if the block should be finished.
-