From 9d5eb4063cba0af282644c54ce9b164d4daee6d7 Mon Sep 17 00:00:00 2001 From: Fenggang Wu Date: Tue, 21 Aug 2018 17:06:44 -0700 Subject: [PATCH] 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 --- table/block.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/table/block.cc b/table/block.cc index f26416e1b..2b3bc0050 100644 --- a/table/block.cc +++ b/table/block.cc @@ -725,13 +725,16 @@ uint32_t Block::NumRestarts() const { uint32_t block_footer = DecodeFixed32(data_ + size_ - sizeof(uint32_t)); uint32_t num_restarts = block_footer; if (size_ > kMaxBlockSizeSupportedByHashIndex) { - // We ensure a block with HashIndex is less than 64KiB in BlockBuilder. - // Therefore the footer cannot be encoded as a packed index type and + // In BlockBuilder, we have ensured a block with HashIndex is less than + // 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. - // Such check can ensure legacy block with a vary large num_restarts - // i.e. >= 0x10000000 can be interpreted correctly as no HashIndex. - // If a legacy block hash a num_restarts >= 0x10000000, size_ will be - // much large than 64KiB. + // + // Such check is for backward compatibility. We can ensure legacy block + // with a vary large num_restarts i.e. >= 0x80000000 can be interpreted + // correctly as no HashIndex even if the MSB of num_restarts is set. return num_restarts; } BlockBasedTableOptions::DataBlockIndexType index_type;