diff options
author | Akanksha Mahajan <akankshamahajan@fb.com> | 2020-07-01 14:56:48 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2020-07-01 14:58:08 -0700 |
commit | 5edfe3a3d89e29515decb3bea9195ae880462762 (patch) | |
tree | 9f2823bbb87df2e4f1eb65b9e002fc89816f56f7 /table | |
parent | c25a014792f53cfa2bd7ecbe19a6ec7e11336098 (diff) |
Update Flush policy in PartitionedIndexBuilder on switching from user-key to internal-key mode (#7022)
Summary:
When format_version is high enough to support user-key and there are index entries for same user key that spans multiple data blocks then it changes from user-key mode to internal-key mode. But the flush policy is not reset to point to Block Builder of internal-keys. After this switch, no entries are added to user key index partition result, thus it never triggers flushing the block.
Fix: After adding the entry in sub_builder_index_, if there is a switch from user-key to internal-key, then flush policy is updated to point to Block Builder of internal-keys index partition.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7022
Test Plan:
1. make check -j64
2. Added one unit test case
Reviewed By: ajkr
Differential Revision: D22197734
Pulled By: akankshamahajan15
fbshipit-source-id: d87e9e46bccab8e896ee6979d6b79c51f73d479e
Diffstat (limited to 'table')
-rw-r--r-- | table/block_based/index_builder.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/table/block_based/index_builder.cc b/table/block_based/index_builder.cc index 277bec61d..a052c65d6 100644 --- a/table/block_based/index_builder.cc +++ b/table/block_based/index_builder.cc @@ -112,6 +112,7 @@ void PartitionedIndexBuilder::MakeNewSubIndexBuilder() { ? sub_index_builder_->index_block_builder_ : sub_index_builder_->index_block_builder_without_seq_)); partition_cut_requested_ = false; + seperator_is_key_plus_seq_ = false; } void PartitionedIndexBuilder::RequestPartitionCut() { @@ -129,9 +130,15 @@ void PartitionedIndexBuilder::AddIndexEntry( } sub_index_builder_->AddIndexEntry(last_key_in_current_block, first_key_in_next_block, block_handle); - if (sub_index_builder_->seperator_is_key_plus_seq_) { - // then we need to apply it to all sub-index builders + if (!seperator_is_key_plus_seq_ && + sub_index_builder_->seperator_is_key_plus_seq_) { + // then we need to apply it to all sub-index builders and reset + // flush_policy to point to Block Builder of sub_index_builder_ that store + // internal keys. seperator_is_key_plus_seq_ = true; + flush_policy_.reset(FlushBlockBySizePolicyFactory::NewFlushBlockPolicy( + table_opt_.metadata_block_size, table_opt_.block_size_deviation, + sub_index_builder_->index_block_builder_)); } sub_index_last_key_ = std::string(*last_key_in_current_block); entries_.push_back( @@ -161,8 +168,14 @@ void PartitionedIndexBuilder::AddIndexEntry( sub_index_builder_->AddIndexEntry(last_key_in_current_block, first_key_in_next_block, block_handle); sub_index_last_key_ = std::string(*last_key_in_current_block); - if (sub_index_builder_->seperator_is_key_plus_seq_) { - // then we need to apply it to all sub-index builders + if (!seperator_is_key_plus_seq_ && + sub_index_builder_->seperator_is_key_plus_seq_) { + // then we need to apply it to all sub-index builders and reset + // flush_policy to point to Block Builder of sub_index_builder_ that store + // internal keys. + flush_policy_.reset(FlushBlockBySizePolicyFactory::NewFlushBlockPolicy( + table_opt_.metadata_block_size, table_opt_.block_size_deviation, + sub_index_builder_->index_block_builder_)); seperator_is_key_plus_seq_ = true; } } |