From 9803e0d813104112f05e2dcea26058cb7cf1e408 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 8 Oct 2015 09:32:50 -0700 Subject: [PATCH] compaction_filter.h cleanup Summary: Two changes: 1. remove *V2 filter stuff. we deprecated that a while ago 2. clarify what happens when user sets max_subcompactions to bigger than 1 Test Plan: none Reviewers: yhchiang, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D47871 --- HISTORY.md | 1 + db/db_impl.h | 1 - include/rocksdb/compaction_filter.h | 96 ++--------------------------- include/rocksdb/options.h | 5 -- 4 files changed, 5 insertions(+), 98 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 0cf2efc06..f4d489b0c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ * Added AddFile() to DB interface. * Added SstFileWriter class. * CompactionFilter has a new method FilterMergeOperand() that RocksDB applies to every merge operand during compaction to decide whether to filter the operand. +* We removed CompactionFilterV2 interfaces from include/rocksdb/compaction_filter.h. The functionality was deprecated already in version 3.13. ## 4.0.0 (9/9/2015) ### New Features diff --git a/db/db_impl.h b/db/db_impl.h index 3f2f97bf6..d7cc9db95 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -51,7 +51,6 @@ class TableCache; class Version; class VersionEdit; class VersionSet; -class CompactionFilterV2; class Arena; class WriteCallback; struct JobContext; diff --git a/include/rocksdb/compaction_filter.h b/include/rocksdb/compaction_filter.h index da809f544..698753c24 100644 --- a/include/rocksdb/compaction_filter.h +++ b/include/rocksdb/compaction_filter.h @@ -78,6 +78,10 @@ class CompactionFilter { // be used by a single thread that is doing the compaction run, and this // call does not need to be thread-safe. However, multiple filters may be // in existence and operating concurrently. + // + // The last paragraph is not true if you set max_subcompactions to more than + // 1. In that case, subcompaction from multiple threads may call a single + // CompactionFilter concurrently. virtual bool Filter(int level, const Slice& key, const Slice& existing_value, @@ -97,39 +101,6 @@ class CompactionFilter { virtual const char* Name() const = 0; }; -// CompactionFilterV2 that buffers kv pairs sharing the same prefix and let -// application layer to make individual decisions for all the kv pairs in the -// buffer. -class CompactionFilterV2 { - public: - virtual ~CompactionFilterV2() {} - - // The compaction process invokes this method for all the kv pairs - // sharing the same prefix. It is a "roll-up" version of CompactionFilter. - // - // Each entry in the return vector indicates if the corresponding kv should - // be preserved in the output of this compaction run. The application can - // inspect the existing values of the keys and make decision based on it. - // - // When a value is to be preserved, the application has the option - // to modify the entry in existing_values and pass it back through an entry - // in new_values. A corresponding values_changed entry needs to be set to - // true in this case. Note that the new_values vector contains only changed - // values, i.e. new_values.size() <= values_changed.size(). - // - typedef std::vector SliceVector; - virtual std::vector Filter(int level, - const SliceVector& keys, - const SliceVector& existing_values, - std::vector* new_values, - std::vector* values_changed) - const = 0; - - // Returns a name that identifies this compaction filter. - // The name will be printed to LOG file on start up for diagnosis. - virtual const char* Name() const = 0; -}; - // Each compaction will create a new CompactionFilter allowing the // application to know about different compactions class CompactionFilterFactory { @@ -157,65 +128,6 @@ class DefaultCompactionFilterFactory : public CompactionFilterFactory { } }; -// Each compaction will create a new CompactionFilterV2 -// -// CompactionFilterFactoryV2 enables application to specify a prefix and use -// CompactionFilterV2 to filter kv-pairs in batches. Each batch contains all -// the kv-pairs sharing the same prefix. -// -// This is useful for applications that require grouping kv-pairs in -// compaction filter to make a purge/no-purge decision. For example, if the -// key prefix is user id and the rest of key represents the type of value. -// This batching filter will come in handy if the application's compaction -// filter requires knowledge of all types of values for any user id. -// -class CompactionFilterFactoryV2 { - public: - // NOTE: CompactionFilterFactoryV2 will not delete prefix_extractor - explicit CompactionFilterFactoryV2(const SliceTransform* prefix_extractor) - : prefix_extractor_(prefix_extractor) { } - - virtual ~CompactionFilterFactoryV2() { } - - virtual std::unique_ptr CreateCompactionFilterV2( - const CompactionFilterContext& context) = 0; - - // Returns a name that identifies this compaction filter factory. - virtual const char* Name() const = 0; - - const SliceTransform* GetPrefixExtractor() const { - return prefix_extractor_; - } - - void SetPrefixExtractor(const SliceTransform* prefix_extractor) { - prefix_extractor_ = prefix_extractor; - } - - private: - // Prefix extractor for compaction filter v2 - // Keys sharing the same prefix will be buffered internally. - // Client can implement a Filter callback function to operate on the buffer - const SliceTransform* prefix_extractor_; -}; - -// Default implementation of CompactionFilterFactoryV2 which does not -// return any filter -class DefaultCompactionFilterFactoryV2 : public CompactionFilterFactoryV2 { - public: - explicit DefaultCompactionFilterFactoryV2() - : CompactionFilterFactoryV2(nullptr) { } - - virtual std::unique_ptr - CreateCompactionFilterV2( - const CompactionFilterContext& context) override { - return std::unique_ptr(nullptr); - } - - virtual const char* Name() const override { - return "DefaultCompactionFilterFactoryV2"; - } -}; - } // namespace rocksdb #endif // STORAGE_ROCKSDB_INCLUDE_COMPACTION_FILTER_H_ diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index d4066cf20..16aa3782b 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -30,7 +30,6 @@ namespace rocksdb { class Cache; class CompactionFilter; class CompactionFilterFactory; -class CompactionFilterFactoryV2; class Comparator; class Env; enum InfoLogLevel : unsigned char; @@ -226,10 +225,6 @@ struct ColumnFamilyOptions { // Default: nullptr std::shared_ptr compaction_filter_factory; - // This is deprecated. Talk to us if you depend on - // compaction_filter_factory_v2 and we'll put it back - // std::shared_ptr compaction_filter_factory_v2; - // ------------------- // Parameters that affect performance