Package org.apache.hadoop.hbase.io.hfile
Interface BlockCompressedSizePredicator
- All Known Implementing Classes:
PreviousBlockCompressionRatePredicator
,UncompressedBlockSizePredicator
Allows for defining different compression rate predicates on its implementing classes. Useful
when compression is in place, and we want to define block size based on the compressed size,
rather than the default behaviour that considers the uncompressed size only. Since we don't
actually know the compressed size until we actual apply compression in the block byte buffer, we
need to "predicate" this compression rate and minimize compression execution to avoid excessive
resources usage. Different approaches for predicating the compressed block size can be defined by
implementing classes. The
updateLatestBlockSizes
allows for updating uncompressed
and compressed size values, and is called during block finishing (when we finally apply
compression on the block data). Final block size predicate logic is implemented in
shouldFinishBlock
, which is called by the block writer once uncompressed size has
reached the configured BLOCK size, and additional checks should be applied to decide if the block
can be finished.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
shouldFinishBlock
(int uncompressed) Decides if the block should be finished based on the comparison of its uncompressed size against an adjusted size based on a predicated compression factor.void
updateLatestBlockSizes
(HFileContext context, int uncompressed, int compressed) Updates the predicator with both compressed and uncompressed sizes of latest block written.
-
Field Details
-
BLOCK_COMPRESSED_SIZE_PREDICATOR
- See Also:
-
MAX_BLOCK_SIZE_UNCOMPRESSED
- See Also:
-
-
Method Details
-
updateLatestBlockSizes
Updates the predicator with both compressed and uncompressed sizes of latest block written. To be called once the block is finshed and flushed to disk after compression.- Parameters:
context
- the HFileContext containg the configured max block size.uncompressed
- the uncompressed size of last block written.compressed
- the compressed size of last block written.
-
shouldFinishBlock
Decides if the block should be finished based on the comparison of its uncompressed size against an adjusted size based on a predicated compression factor.- Parameters:
uncompressed
- true if the block should be finished.
-