Clean up PartitionedFilterBlockBuilder (#6299)

Summary:
Remove the redundant PartitionedFilterBlockBuilder::num_added_ and ::NumAdded since the parent class, FullFilterBlockBuilder, already provides them.
Also rename filters_in_partition_ and filters_per_partition_ to keys_added_to_partition_ and keys_per_partition_ to improve readability.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6299

Test Plan: make check

Differential Revision: D19413278

Pulled By: pdillinger

fbshipit-source-id: 04926ee7874477d659cb2b6ae03f2d995fb747e5
main
Peter Dillinger 5 years ago committed by Facebook Github Bot
parent bd698e4f55
commit 986df37135
  1. 14
      table/block_based/partitioned_filter_block.cc
  2. 12
      table/block_based/partitioned_filter_block.h

@ -32,9 +32,8 @@ PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder(
true /*use_delta_encoding*/, true /*use_delta_encoding*/,
use_value_delta_encoding), use_value_delta_encoding),
p_index_builder_(p_index_builder), p_index_builder_(p_index_builder),
filters_in_partition_(0), keys_added_to_partition_(0) {
num_added_(0) { keys_per_partition_ =
filters_per_partition_ =
filter_bits_builder_->CalculateNumEntry(partition_size); filter_bits_builder_->CalculateNumEntry(partition_size);
} }
@ -43,7 +42,7 @@ PartitionedFilterBlockBuilder::~PartitionedFilterBlockBuilder() {}
void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock( void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
const Slice* next_key) { const Slice* next_key) {
// Use == to send the request only once // Use == to send the request only once
if (filters_in_partition_ == filters_per_partition_) { if (keys_added_to_partition_ == keys_per_partition_) {
// Currently only index builder is in charge of cutting a partition. We keep // Currently only index builder is in charge of cutting a partition. We keep
// requesting until it is granted. // requesting until it is granted.
p_index_builder_->RequestPartitionCut(); p_index_builder_->RequestPartitionCut();
@ -65,7 +64,7 @@ void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
Slice filter = filter_bits_builder_->Finish(&filter_gc.back()); Slice filter = filter_bits_builder_->Finish(&filter_gc.back());
std::string& index_key = p_index_builder_->GetPartitionKey(); std::string& index_key = p_index_builder_->GetPartitionKey();
filters.push_back({index_key, filter}); filters.push_back({index_key, filter});
filters_in_partition_ = 0; keys_added_to_partition_ = 0;
Reset(); Reset();
} }
@ -75,9 +74,8 @@ void PartitionedFilterBlockBuilder::Add(const Slice& key) {
} }
void PartitionedFilterBlockBuilder::AddKey(const Slice& key) { void PartitionedFilterBlockBuilder::AddKey(const Slice& key) {
filter_bits_builder_->AddKey(key); FullFilterBlockBuilder::AddKey(key);
filters_in_partition_++; keys_added_to_partition_++;
num_added_++;
} }
Slice PartitionedFilterBlockBuilder::Finish( Slice PartitionedFilterBlockBuilder::Finish(

@ -34,8 +34,6 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
void AddKey(const Slice& key) override; void AddKey(const Slice& key) override;
void Add(const Slice& key) override; void Add(const Slice& key) override;
size_t NumAdded() const override { return num_added_; }
virtual Slice Finish(const BlockHandle& last_partition_block_handle, virtual Slice Finish(const BlockHandle& last_partition_block_handle,
Status* status) override; Status* status) override;
@ -60,12 +58,10 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
// optimizations did not realize we can use different number of partitions and // optimizations did not realize we can use different number of partitions and
// eliminate p_index_builder_ // eliminate p_index_builder_
PartitionedIndexBuilder* const p_index_builder_; PartitionedIndexBuilder* const p_index_builder_;
// The desired number of filters per partition // The desired number of keys per partition
uint32_t filters_per_partition_; uint32_t keys_per_partition_;
// The current number of filters in the last partition // The number of keys added to the last partition so far
uint32_t filters_in_partition_; uint32_t keys_added_to_partition_;
// Number of keys added
size_t num_added_;
BlockHandle last_encoded_handle_; BlockHandle last_encoded_handle_;
}; };

Loading…
Cancel
Save