Skip to content

Commit

Permalink
Clean up PartitionedFilterBlockBuilder (facebook#6299)
Browse files Browse the repository at this point in the history
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: facebook#6299

Test Plan: make check

Differential Revision: D19413278

Pulled By: pdillinger

fbshipit-source-id: 04926ee7874477d659cb2b6ae03f2d995fb747e5
  • Loading branch information
pdillinger authored and facebook-github-bot committed Jan 27, 2020
1 parent bd698e4 commit 986df37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
14 changes: 6 additions & 8 deletions table/block_based/partitioned_filter_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder(
true /*use_delta_encoding*/,
use_value_delta_encoding),
p_index_builder_(p_index_builder),
filters_in_partition_(0),
num_added_(0) {
filters_per_partition_ =
keys_added_to_partition_(0) {
keys_per_partition_ =
filter_bits_builder_->CalculateNumEntry(partition_size);
}

Expand All @@ -43,7 +42,7 @@ PartitionedFilterBlockBuilder::~PartitionedFilterBlockBuilder() {}
void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
const Slice* next_key) {
// 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
// requesting until it is granted.
p_index_builder_->RequestPartitionCut();
Expand All @@ -65,7 +64,7 @@ void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
Slice filter = filter_bits_builder_->Finish(&filter_gc.back());
std::string& index_key = p_index_builder_->GetPartitionKey();
filters.push_back({index_key, filter});
filters_in_partition_ = 0;
keys_added_to_partition_ = 0;
Reset();
}

Expand All @@ -75,9 +74,8 @@ void PartitionedFilterBlockBuilder::Add(const Slice& key) {
}

void PartitionedFilterBlockBuilder::AddKey(const Slice& key) {
filter_bits_builder_->AddKey(key);
filters_in_partition_++;
num_added_++;
FullFilterBlockBuilder::AddKey(key);
keys_added_to_partition_++;
}

Slice PartitionedFilterBlockBuilder::Finish(
Expand Down
12 changes: 4 additions & 8 deletions table/block_based/partitioned_filter_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
void AddKey(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,
Status* status) override;

Expand All @@ -60,12 +58,10 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
// optimizations did not realize we can use different number of partitions and
// eliminate p_index_builder_
PartitionedIndexBuilder* const p_index_builder_;
// The desired number of filters per partition
uint32_t filters_per_partition_;
// The current number of filters in the last partition
uint32_t filters_in_partition_;
// Number of keys added
size_t num_added_;
// The desired number of keys per partition
uint32_t keys_per_partition_;
// The number of keys added to the last partition so far
uint32_t keys_added_to_partition_;
BlockHandle last_encoded_handle_;
};

Expand Down

0 comments on commit 986df37

Please sign in to comment.