Fix calculating filter partition target size

Summary:
block_size_deviation is in percentage while the partition size is in bytes. The current code fails to take that into account resulting into very large target size for filter partitions.
Closes https://github.com/facebook/rocksdb/pull/3187

Differential Revision: D6376069

Pulled By: maysamyabandeh

fbshipit-source-id: 276546fc68f50e0da32c462abb46f6cf676db9b2
main
Maysam Yabandeh 7 years ago committed by Facebook Github Bot
parent 0996e140bd
commit 30285ee31c
  1. 4
      table/block_based_table_builder.cc
  2. 9
      table/partitioned_filter_block_test.cc

@ -78,8 +78,8 @@ FilterBlockBuilder* CreateFilterBlockBuilder(
// as partition size.
assert(table_opt.block_size_deviation <= 100);
auto partition_size = static_cast<uint32_t>(
table_opt.metadata_block_size *
(100 - table_opt.block_size_deviation));
((table_opt.metadata_block_size *
(100 - table_opt.block_size_deviation)) + 99) / 100);
partition_size = std::max(partition_size, static_cast<uint32_t>(1));
return new PartitionedFilterBlockBuilder(
opt.prefix_extractor, table_opt.whole_key_filtering,

@ -75,7 +75,8 @@ class PartitionedFilterBlockTest : public testing::Test {
auto partition_size =
filter_bits_reader->CalculateSpace(num_keys, &dont_care1, &dont_care2);
delete filter_bits_reader;
return partition_size + table_options_.block_size_deviation;
return partition_size +
partition_size * table_options_.block_size_deviation / 100;
}
int last_offset = 10;
@ -94,8 +95,10 @@ class PartitionedFilterBlockTest : public testing::Test {
PartitionedIndexBuilder* const p_index_builder) {
assert(table_options_.block_size_deviation <= 100);
auto partition_size = static_cast<uint32_t>(
table_options_.metadata_block_size *
( 100 - table_options_.block_size_deviation));
((table_options_.metadata_block_size *
(100 - table_options_.block_size_deviation)) +
99) /
100);
partition_size = std::max(partition_size, static_cast<uint32_t>(1));
return new PartitionedFilterBlockBuilder(
nullptr, table_options_.whole_key_filtering,

Loading…
Cancel
Save