Skip to content

Commit

Permalink
move compaction_filter to immutable_options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lei Jin committed Sep 8, 2014
1 parent 048560a commit 659d2d5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 5 additions & 5 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion include/rocksdb/immutable_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions util/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 659d2d5

Please sign in to comment.