Skip to content

Commit 659d2d5

Browse files
author
Lei Jin
committed
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
1 parent 048560a commit 659d2d5

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

db/db_impl.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -2643,12 +2643,12 @@ Status DBImpl::ProcessKeyValueCompaction(
26432643
cfd->user_comparator(), cfd->ioptions()->merge_operator,
26442644
db_options_.info_log.get(), cfd->options()->min_partial_merge_operands,
26452645
false /* internal key corruption is expected */);
2646-
auto compaction_filter = cfd->options()->compaction_filter;
2646+
auto compaction_filter = cfd->ioptions()->compaction_filter;
26472647
std::unique_ptr<CompactionFilter> compaction_filter_from_factory = nullptr;
26482648
if (!compaction_filter) {
26492649
auto context = compact->GetFilterContextV1();
26502650
compaction_filter_from_factory =
2651-
cfd->options()->compaction_filter_factory->CreateCompactionFilter(
2651+
cfd->ioptions()->compaction_filter_factory->CreateCompactionFilter(
26522652
context);
26532653
compaction_filter = compaction_filter_from_factory.get();
26542654
}
@@ -3085,8 +3085,8 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
30853085
= nullptr;
30863086
auto context = compact->GetFilterContext();
30873087
compaction_filter_from_factory_v2 =
3088-
cfd->options()->compaction_filter_factory_v2->CreateCompactionFilterV2(
3089-
context);
3088+
cfd->ioptions()->compaction_filter_factory_v2->
3089+
CreateCompactionFilterV2(context);
30903090
auto compaction_filter_v2 =
30913091
compaction_filter_from_factory_v2.get();
30923092

@@ -3116,7 +3116,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
31163116
continue;
31173117
} else {
31183118
const SliceTransform* transformer =
3119-
cfd->options()->compaction_filter_factory_v2->GetPrefixExtractor();
3119+
cfd->ioptions()->compaction_filter_factory_v2->GetPrefixExtractor();
31203120
const auto key_prefix = transformer->Transform(ikey.user_key);
31213121
if (!prefix_initialized) {
31223122
compact->cur_prefix_ = key_prefix.ToString();

include/rocksdb/immutable_options.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ namespace rocksdb {
1313
// ImmutableCFOptions is a data struct used by RocksDB internal. It contains a
1414
// subset of Options that should not be changed during the entire lifetime
1515
// of DB. You shouldn't need to access this data structure unless you are
16-
// implementing a new TableFactory.
16+
// implementing a new TableFactory. Raw pointers defined in this struct do
17+
// not have ownership to the data they point to. Options contains shared_ptr
18+
// to these data.
1719
struct ImmutableCFOptions {
1820
explicit ImmutableCFOptions(const Options& options);
1921

@@ -27,6 +29,12 @@ struct ImmutableCFOptions {
2729

2830
MergeOperator* merge_operator;
2931

32+
const CompactionFilter* compaction_filter;
33+
34+
CompactionFilterFactory* compaction_filter_factory;
35+
36+
CompactionFilterFactoryV2* compaction_filter_factory_v2;
37+
3038
Logger* info_log;
3139

3240
Statistics* statistics;

util/options.cc

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ ImmutableCFOptions::ImmutableCFOptions(const Options& options)
3838
prefix_extractor(options.prefix_extractor.get()),
3939
comparator(options.comparator),
4040
merge_operator(options.merge_operator.get()),
41+
compaction_filter(options.compaction_filter),
42+
compaction_filter_factory(options.compaction_filter_factory.get()),
43+
compaction_filter_factory_v2(options.compaction_filter_factory_v2.get()),
4144
info_log(options.info_log.get()),
4245
statistics(options.statistics.get()),
4346
env(options.env),

0 commit comments

Comments
 (0)