DataBlockHashIndex: fix comment in NumRestarts() (#4286)
Summary: Improve the description of the backward compatibility check in NumRestarts() Pull Request resolved: https://github.com/facebook/rocksdb/pull/4286 Differential Revision: D9412490 Pulled By: fgwu fbshipit-source-id: ea7dd5c61d8ff8eacef623b729d4e4fd53cca066
This commit is contained in:
parent
4f12d49daf
commit
640cfa7c33
@ -725,13 +725,16 @@ uint32_t Block::NumRestarts() const {
|
|||||||
uint32_t block_footer = DecodeFixed32(data_ + size_ - sizeof(uint32_t));
|
uint32_t block_footer = DecodeFixed32(data_ + size_ - sizeof(uint32_t));
|
||||||
uint32_t num_restarts = block_footer;
|
uint32_t num_restarts = block_footer;
|
||||||
if (size_ > kMaxBlockSizeSupportedByHashIndex) {
|
if (size_ > kMaxBlockSizeSupportedByHashIndex) {
|
||||||
// We ensure a block with HashIndex is less than 64KiB in BlockBuilder.
|
// In BlockBuilder, we have ensured a block with HashIndex is less than
|
||||||
// Therefore the footer cannot be encoded as a packed index type and
|
// kMaxBlockSizeSupportedByHashIndex (64KiB).
|
||||||
|
//
|
||||||
|
// Therefore, if we encounter a block with a size > 64KiB, the block
|
||||||
|
// cannot have HashIndex. So the footer will directly interpreted as
|
||||||
// num_restarts.
|
// num_restarts.
|
||||||
// Such check can ensure legacy block with a vary large num_restarts
|
//
|
||||||
// i.e. >= 0x10000000 can be interpreted correctly as no HashIndex.
|
// Such check is for backward compatibility. We can ensure legacy block
|
||||||
// If a legacy block hash a num_restarts >= 0x10000000, size_ will be
|
// with a vary large num_restarts i.e. >= 0x80000000 can be interpreted
|
||||||
// much large than 64KiB.
|
// correctly as no HashIndex even if the MSB of num_restarts is set.
|
||||||
return num_restarts;
|
return num_restarts;
|
||||||
}
|
}
|
||||||
BlockBasedTableOptions::DataBlockIndexType index_type;
|
BlockBasedTableOptions::DataBlockIndexType index_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user