mirror of https://github.com/facebook/rocksdb.git
move compaction_filter to immutable_options
Summary: all shared_ptrs are in immutable_options now. This will also make options assignment a little cheaper Test Plan: make release Reviewers: sdong, yhchiang, igor Reviewed By: igor Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D23001
This commit is contained in:
parent
048560a642
commit
659d2d50c3
|
@ -2643,12 +2643,12 @@ Status DBImpl::ProcessKeyValueCompaction(
|
|||
cfd->user_comparator(), cfd->ioptions()->merge_operator,
|
||||
db_options_.info_log.get(), cfd->options()->min_partial_merge_operands,
|
||||
false /* internal key corruption is expected */);
|
||||
auto compaction_filter = cfd->options()->compaction_filter;
|
||||
auto compaction_filter = cfd->ioptions()->compaction_filter;
|
||||
std::unique_ptr<CompactionFilter> compaction_filter_from_factory = nullptr;
|
||||
if (!compaction_filter) {
|
||||
auto context = compact->GetFilterContextV1();
|
||||
compaction_filter_from_factory =
|
||||
cfd->options()->compaction_filter_factory->CreateCompactionFilter(
|
||||
cfd->ioptions()->compaction_filter_factory->CreateCompactionFilter(
|
||||
context);
|
||||
compaction_filter = compaction_filter_from_factory.get();
|
||||
}
|
||||
|
@ -3085,8 +3085,8 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
|
|||
= nullptr;
|
||||
auto context = compact->GetFilterContext();
|
||||
compaction_filter_from_factory_v2 =
|
||||
cfd->options()->compaction_filter_factory_v2->CreateCompactionFilterV2(
|
||||
context);
|
||||
cfd->ioptions()->compaction_filter_factory_v2->
|
||||
CreateCompactionFilterV2(context);
|
||||
auto compaction_filter_v2 =
|
||||
compaction_filter_from_factory_v2.get();
|
||||
|
||||
|
@ -3116,7 +3116,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
|
|||
continue;
|
||||
} else {
|
||||
const SliceTransform* transformer =
|
||||
cfd->options()->compaction_filter_factory_v2->GetPrefixExtractor();
|
||||
cfd->ioptions()->compaction_filter_factory_v2->GetPrefixExtractor();
|
||||
const auto key_prefix = transformer->Transform(ikey.user_key);
|
||||
if (!prefix_initialized) {
|
||||
compact->cur_prefix_ = key_prefix.ToString();
|
||||
|
|
|
@ -13,7 +13,9 @@ namespace rocksdb {
|
|||
// ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
|
||||
// subset of Options that should not be changed during the entire lifetime
|
||||
// of DB. You shouldn't need to access this data structure unless you are
|
||||
// implementing a new TableFactory.
|
||||
// implementing a new TableFactory. Raw pointers defined in this struct do
|
||||
// not have ownership to the data they point to. Options contains shared_ptr
|
||||
// to these data.
|
||||
struct ImmutableCFOptions {
|
||||
explicit ImmutableCFOptions(const Options& options);
|
||||
|
||||
|
@ -27,6 +29,12 @@ struct ImmutableCFOptions {
|
|||
|
||||
MergeOperator* merge_operator;
|
||||
|
||||
const CompactionFilter* compaction_filter;
|
||||
|
||||
CompactionFilterFactory* compaction_filter_factory;
|
||||
|
||||
CompactionFilterFactoryV2* compaction_filter_factory_v2;
|
||||
|
||||
Logger* info_log;
|
||||
|
||||
Statistics* statistics;
|
||||
|
|
|
@ -38,6 +38,9 @@ ImmutableCFOptions::ImmutableCFOptions(const Options& options)
|
|||
prefix_extractor(options.prefix_extractor.get()),
|
||||
comparator(options.comparator),
|
||||
merge_operator(options.merge_operator.get()),
|
||||
compaction_filter(options.compaction_filter),
|
||||
compaction_filter_factory(options.compaction_filter_factory.get()),
|
||||
compaction_filter_factory_v2(options.compaction_filter_factory_v2.get()),
|
||||
info_log(options.info_log.get()),
|
||||
statistics(options.statistics.get()),
|
||||
env(options.env),
|
||||
|
|
Loading…
Reference in New Issue