提交 9eca6d65 编写于 作者: A Andrew Kryczka 提交者: Facebook GitHub Bot

fix comparison count for format_version=3 indexes (#6650)

Summary:
In index blocks since `format_version=3`, user keys are written
rather than internal keys. When reading such blocks, the comparator is
obtained via `InternalKeyComparator::user_comparator()`. That function
must not return an unwrapped result as the wrapper class provides
accounting logic to populate `PerfContext::user_key_comparison_count`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6650

Test Plan:
ran db_bench and verified
`PerfContext::user_key_comparison_count` became larger.

Reviewed By: cheng-chang

Differential Revision: D20866325

Pulled By: ajkr

fbshipit-source-id: ad755d46bda31157dacc5b66e532279f19ad538c
上级 79c838eb
......@@ -9,6 +9,7 @@
### Bug Fixes
* Fix a bug when making options.bottommost_compression, options.compression_opts and options.bottommost_compression_opts dynamically changeable: the modified values are not written to option files or returned back to users when being queried.
* Fix a bug where index key comparisons were unaccounted in `PerfContext::user_key_comparison_count` for lookups in files written with `format_version >= 3`.
## 6.9.0 (03/29/2020)
### Behavior changes
......
......@@ -502,9 +502,14 @@ class IndexBlockIter final : public BlockIter<IndexValue> {
SequenceNumber global_seqno, BlockPrefixIndex* prefix_index,
bool have_first_key, bool key_includes_seq,
bool value_is_full, bool block_contents_pinned) {
InitializeBase(key_includes_seq ? comparator : user_comparator, data,
restarts, num_restarts, kDisableGlobalSequenceNumber,
block_contents_pinned);
if (!key_includes_seq) {
user_comparator_wrapper_ = std::unique_ptr<UserComparatorWrapper>(
new UserComparatorWrapper(user_comparator));
}
InitializeBase(
key_includes_seq ? comparator : user_comparator_wrapper_.get(), data,
restarts, num_restarts, kDisableGlobalSequenceNumber,
block_contents_pinned);
key_includes_seq_ = key_includes_seq;
key_.SetIsUserKey(!key_includes_seq_);
prefix_index_ = prefix_index;
......@@ -573,6 +578,7 @@ class IndexBlockIter final : public BlockIter<IndexValue> {
}
private:
std::unique_ptr<UserComparatorWrapper> user_comparator_wrapper_;
// Key is in InternalKey format
bool key_includes_seq_;
bool value_delta_encoded_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册