mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 20:43:57 +00:00
4b86fe1123
Summary: Help users that would benefit most from new Bloom filter implementation by logging a warning that recommends the using format_version >= 5. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6312 Test Plan: $ (for BPK in 10 13 14 19 20 50; do ./filter_bench -quick -impl=0 -bits_per_key=$BPK -m_queries=1 2>&1; done) | grep 'its/key' Bits/key actual: 10.0647 Bits/key actual: 13.0593 [WARN] [/block_based/filter_policy.cc:546] Using legacy Bloom filter with high (14) bits/key. Significant filter space and/or accuracy improvement is available with format_verion>=5. Bits/key actual: 14.0581 [WARN] [/block_based/filter_policy.cc:546] Using legacy Bloom filter with high (19) bits/key. Significant filter space and/or accuracy improvement is available with format_verion>=5. Bits/key actual: 19.0542 [WARN] [/block_based/filter_policy.cc:546] Using legacy Bloom filter with high (20) bits/key. Dramatic filter space and/or accuracy improvement is available with format_verion>=5. Bits/key actual: 20.0584 [WARN] [/block_based/filter_policy.cc:546] Using legacy Bloom filter with high (50) bits/key. Dramatic filter space and/or accuracy improvement is available with format_verion>=5. Bits/key actual: 50.0577 Differential Revision: D19457191 Pulled By: pdillinger fbshipit-source-id: 073d94cde5c70e03a160f953e1100c15ea83eda4
57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
// Copyright (c) 2019-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
#pragma once
|
|
|
|
#include "rocksdb/filter_policy.h"
|
|
#include "table/block_based/block_based_filter_block.h"
|
|
#include "table/block_based/block_based_table_reader.h"
|
|
#include "table/block_based/filter_policy_internal.h"
|
|
|
|
namespace rocksdb {
|
|
namespace mock {
|
|
|
|
class MockBlockBasedTable : public BlockBasedTable {
|
|
public:
|
|
explicit MockBlockBasedTable(Rep* rep)
|
|
: BlockBasedTable(rep, nullptr /* block_cache_tracer */) {}
|
|
};
|
|
|
|
class MockBlockBasedTableTester {
|
|
static constexpr int kMockLevel = 0;
|
|
|
|
public:
|
|
Options options_;
|
|
ImmutableCFOptions ioptions_;
|
|
EnvOptions env_options_;
|
|
BlockBasedTableOptions table_options_;
|
|
InternalKeyComparator icomp_;
|
|
std::unique_ptr<BlockBasedTable> table_;
|
|
|
|
MockBlockBasedTableTester(const FilterPolicy *filter_policy)
|
|
: ioptions_(options_),
|
|
env_options_(options_),
|
|
icomp_(options_.comparator) {
|
|
table_options_.filter_policy.reset(filter_policy);
|
|
|
|
constexpr bool skip_filters = false;
|
|
constexpr bool immortal_table = false;
|
|
table_.reset(new MockBlockBasedTable(new BlockBasedTable::Rep(
|
|
ioptions_, env_options_, table_options_, icomp_, skip_filters,
|
|
kMockLevel, immortal_table)));
|
|
}
|
|
|
|
FilterBitsBuilder* GetBuilder() const {
|
|
FilterBuildingContext context(table_options_);
|
|
context.column_family_name = "mock_cf";
|
|
context.compaction_style = ioptions_.compaction_style;
|
|
context.level_at_creation = kMockLevel;
|
|
context.info_log = ioptions_.info_log;
|
|
return BloomFilterPolicy::GetBuilderFromContext(context);
|
|
}
|
|
};
|
|
|
|
} // namespace mock
|
|
} // namespace rocksdb
|