diff --git a/db/db_impl.cc b/db/db_impl.cc index 54c14b455..a7c9206f9 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -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 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(); diff --git a/include/rocksdb/immutable_options.h b/include/rocksdb/immutable_options.h index be7b095e0..f3e41c89e 100644 --- a/include/rocksdb/immutable_options.h +++ b/include/rocksdb/immutable_options.h @@ -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; diff --git a/util/options.cc b/util/options.cc index a4e83cc78..4def58ffe 100644 --- a/util/options.cc +++ b/util/options.cc @@ -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),