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,
|
cfd->user_comparator(), cfd->ioptions()->merge_operator,
|
||||||
db_options_.info_log.get(), cfd->options()->min_partial_merge_operands,
|
db_options_.info_log.get(), cfd->options()->min_partial_merge_operands,
|
||||||
false /* internal key corruption is expected */);
|
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;
|
std::unique_ptr<CompactionFilter> compaction_filter_from_factory = nullptr;
|
||||||
if (!compaction_filter) {
|
if (!compaction_filter) {
|
||||||
auto context = compact->GetFilterContextV1();
|
auto context = compact->GetFilterContextV1();
|
||||||
compaction_filter_from_factory =
|
compaction_filter_from_factory =
|
||||||
cfd->options()->compaction_filter_factory->CreateCompactionFilter(
|
cfd->ioptions()->compaction_filter_factory->CreateCompactionFilter(
|
||||||
context);
|
context);
|
||||||
compaction_filter = compaction_filter_from_factory.get();
|
compaction_filter = compaction_filter_from_factory.get();
|
||||||
}
|
}
|
||||||
@ -3085,8 +3085,8 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
|
|||||||
= nullptr;
|
= nullptr;
|
||||||
auto context = compact->GetFilterContext();
|
auto context = compact->GetFilterContext();
|
||||||
compaction_filter_from_factory_v2 =
|
compaction_filter_from_factory_v2 =
|
||||||
cfd->options()->compaction_filter_factory_v2->CreateCompactionFilterV2(
|
cfd->ioptions()->compaction_filter_factory_v2->
|
||||||
context);
|
CreateCompactionFilterV2(context);
|
||||||
auto compaction_filter_v2 =
|
auto compaction_filter_v2 =
|
||||||
compaction_filter_from_factory_v2.get();
|
compaction_filter_from_factory_v2.get();
|
||||||
|
|
||||||
@ -3116,7 +3116,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
const SliceTransform* transformer =
|
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);
|
const auto key_prefix = transformer->Transform(ikey.user_key);
|
||||||
if (!prefix_initialized) {
|
if (!prefix_initialized) {
|
||||||
compact->cur_prefix_ = key_prefix.ToString();
|
compact->cur_prefix_ = key_prefix.ToString();
|
||||||
|
@ -13,7 +13,9 @@ namespace rocksdb {
|
|||||||
// ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
|
// ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
|
||||||
// subset of Options that should not be changed during the entire lifetime
|
// 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
|
// 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 {
|
struct ImmutableCFOptions {
|
||||||
explicit ImmutableCFOptions(const Options& options);
|
explicit ImmutableCFOptions(const Options& options);
|
||||||
|
|
||||||
@ -27,6 +29,12 @@ struct ImmutableCFOptions {
|
|||||||
|
|
||||||
MergeOperator* merge_operator;
|
MergeOperator* merge_operator;
|
||||||
|
|
||||||
|
const CompactionFilter* compaction_filter;
|
||||||
|
|
||||||
|
CompactionFilterFactory* compaction_filter_factory;
|
||||||
|
|
||||||
|
CompactionFilterFactoryV2* compaction_filter_factory_v2;
|
||||||
|
|
||||||
Logger* info_log;
|
Logger* info_log;
|
||||||
|
|
||||||
Statistics* statistics;
|
Statistics* statistics;
|
||||||
|
@ -38,6 +38,9 @@ ImmutableCFOptions::ImmutableCFOptions(const Options& options)
|
|||||||
prefix_extractor(options.prefix_extractor.get()),
|
prefix_extractor(options.prefix_extractor.get()),
|
||||||
comparator(options.comparator),
|
comparator(options.comparator),
|
||||||
merge_operator(options.merge_operator.get()),
|
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()),
|
info_log(options.info_log.get()),
|
||||||
statistics(options.statistics.get()),
|
statistics(options.statistics.get()),
|
||||||
env(options.env),
|
env(options.env),
|
||||||
|
Loading…
Reference in New Issue
Block a user