Use nullptr for default compaction_filter_factory
Summary: Replacing the default value for compaction_filter_factory and compaction_filter_factory_v2 to be nullptr instead of DefaultCompactionFilterFactory / DefaultCompactionFilterFactoryV2 The reason for this is to be able to determine easily if we have compaction filter factory or not without depending on RTTI Test Plan: make check Reviewers: yoshinorim, ott, igor, sdong Reviewed By: sdong Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D39693
This commit is contained in:
parent
21f2492ac0
commit
643bbbf081
@ -9,6 +9,7 @@
|
||||
* Move listeners from ColumnFamilyOptions to DBOptions.
|
||||
* Add max_write_buffer_number_to_maintain option
|
||||
* DB::CompactRange()'s parameter reduce_level is changed to change_level, to allow users to move levels to lower levels if allowed. It can be used to migrate a DB from options.level_compaction_dynamic_level_bytes=false to options.level_compaction_dynamic_level_bytes.true.
|
||||
* Change default value for options.compaction_filter_factory and options.compaction_filter_factory_v2 to nullptr instead of DefaultCompactionFilterFactory and DefaultCompactionFilterFactoryV2.
|
||||
|
||||
## 3.11.0 (5/19/2015)
|
||||
### New Features
|
||||
|
@ -160,10 +160,8 @@ bool Compaction::IsTrivialMove() const {
|
||||
|
||||
if (is_manual_compaction_ &&
|
||||
(cfd_->ioptions()->compaction_filter != nullptr ||
|
||||
!dynamic_cast<DefaultCompactionFilterFactory*>(
|
||||
cfd_->ioptions()->compaction_filter_factory) ||
|
||||
!dynamic_cast<DefaultCompactionFilterFactoryV2*>(
|
||||
cfd_->ioptions()->compaction_filter_factory_v2))) {
|
||||
cfd_->ioptions()->compaction_filter_factory != nullptr ||
|
||||
cfd_->ioptions()->compaction_filter_factory_v2 != nullptr)) {
|
||||
// This is a manual compaction and we have a compaction filter that should
|
||||
// be executed, we cannot do a trivial move
|
||||
return false;
|
||||
@ -360,6 +358,10 @@ uint64_t Compaction::OutputFilePreallocationSize() {
|
||||
}
|
||||
|
||||
std::unique_ptr<CompactionFilter> Compaction::CreateCompactionFilter() const {
|
||||
if (!cfd_->ioptions()->compaction_filter_factory) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompactionFilter::Context context;
|
||||
context.is_full_compaction = is_full_compaction_;
|
||||
context.is_manual_compaction = is_manual_compaction_;
|
||||
@ -369,6 +371,10 @@ std::unique_ptr<CompactionFilter> Compaction::CreateCompactionFilter() const {
|
||||
|
||||
std::unique_ptr<CompactionFilterV2>
|
||||
Compaction::CreateCompactionFilterV2() const {
|
||||
if (!cfd_->ioptions()->compaction_filter_factory_v2) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompactionFilterContext context;
|
||||
context.is_full_compaction = is_full_compaction_;
|
||||
context.is_manual_compaction = is_manual_compaction_;
|
||||
|
@ -189,13 +189,13 @@ struct ColumnFamilyOptions {
|
||||
// compaction is being used, each created CompactionFilter will only be used
|
||||
// from a single thread and so does not need to be thread-safe.
|
||||
//
|
||||
// Default: a factory that doesn't provide any object
|
||||
// Default: nullptr
|
||||
std::shared_ptr<CompactionFilterFactory> compaction_filter_factory;
|
||||
|
||||
// Version TWO of the compaction_filter_factory
|
||||
// It supports rolling compaction
|
||||
//
|
||||
// Default: a factory that doesn't provide any object
|
||||
// Default: nullptr
|
||||
std::shared_ptr<CompactionFilterFactoryV2> compaction_filter_factory_v2;
|
||||
|
||||
// -------------------
|
||||
|
@ -78,9 +78,8 @@ ColumnFamilyOptions::ColumnFamilyOptions()
|
||||
: comparator(BytewiseComparator()),
|
||||
merge_operator(nullptr),
|
||||
compaction_filter(nullptr),
|
||||
compaction_filter_factory(std::shared_ptr<CompactionFilterFactory>(
|
||||
new DefaultCompactionFilterFactory())),
|
||||
compaction_filter_factory_v2(new DefaultCompactionFilterFactoryV2()),
|
||||
compaction_filter_factory(nullptr),
|
||||
compaction_filter_factory_v2(nullptr),
|
||||
write_buffer_size(4 << 20),
|
||||
max_write_buffer_number(2),
|
||||
min_write_buffer_number_to_merge(1),
|
||||
@ -366,9 +365,10 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
|
||||
Warn(log, " Options.compaction_filter: %s",
|
||||
compaction_filter ? compaction_filter->Name() : "None");
|
||||
Warn(log, " Options.compaction_filter_factory: %s",
|
||||
compaction_filter_factory->Name());
|
||||
compaction_filter_factory ? compaction_filter_factory->Name() : "None");
|
||||
Warn(log, " Options.compaction_filter_factory_v2: %s",
|
||||
compaction_filter_factory_v2->Name());
|
||||
compaction_filter_factory_v2 ? compaction_filter_factory_v2->Name()
|
||||
: "None");
|
||||
Warn(log, " Options.memtable_factory: %s", memtable_factory->Name());
|
||||
Warn(log, " Options.table_factory: %s", table_factory->Name());
|
||||
Warn(log, " table_factory options: %s",
|
||||
|
@ -188,9 +188,15 @@ class TtlCompactionFilterFactory : public CompactionFilterFactory {
|
||||
|
||||
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
|
||||
const CompactionFilter::Context& context) override {
|
||||
std::unique_ptr<const CompactionFilter> user_comp_filter_from_factory =
|
||||
nullptr;
|
||||
if (user_comp_filter_factory_) {
|
||||
user_comp_filter_from_factory =
|
||||
user_comp_filter_factory_->CreateCompactionFilter(context);
|
||||
}
|
||||
|
||||
return std::unique_ptr<TtlCompactionFilter>(new TtlCompactionFilter(
|
||||
ttl_, env_, nullptr,
|
||||
std::move(user_comp_filter_factory_->CreateCompactionFilter(context))));
|
||||
ttl_, env_, nullptr, std::move(user_comp_filter_from_factory)));
|
||||
}
|
||||
|
||||
virtual const char* Name() const override {
|
||||
|
Loading…
Reference in New Issue
Block a user