2019-10-08 05:09:27 +02:00
|
|
|
// 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"
|
2019-11-27 03:18:29 +01:00
|
|
|
#include "table/block_based/block_based_filter_block.h"
|
2019-10-08 05:09:27 +02:00
|
|
|
#include "table/block_based/block_based_table_reader.h"
|
2019-11-27 03:18:29 +01:00
|
|
|
#include "table/block_based/filter_policy_internal.h"
|
2019-10-08 05:09:27 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2019-10-08 05:09:27 +02:00
|
|
|
namespace mock {
|
|
|
|
|
|
|
|
class MockBlockBasedTable : public BlockBasedTable {
|
|
|
|
public:
|
|
|
|
explicit MockBlockBasedTable(Rep* rep)
|
|
|
|
: BlockBasedTable(rep, nullptr /* block_cache_tracer */) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockBlockBasedTableTester {
|
2019-11-27 03:18:29 +01:00
|
|
|
static constexpr int kMockLevel = 0;
|
|
|
|
|
2019-10-08 05:09:27 +02:00
|
|
|
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;
|
2019-11-27 03:18:29 +01:00
|
|
|
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;
|
2020-01-18 04:36:09 +01:00
|
|
|
context.info_log = ioptions_.info_log;
|
2019-11-27 03:18:29 +01:00
|
|
|
return BloomFilterPolicy::GetBuilderFromContext(context);
|
2019-10-08 05:09:27 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mock
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|