diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 20abdd56e..7c6fb162a 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -525,6 +525,9 @@ DEFINE_bool(read_cache_direct_write, true, DEFINE_bool(read_cache_direct_read, true, "Whether to use Direct IO for reading from read cache"); +DEFINE_bool(use_keep_filter, false, + "Whether to use a noop compaction filter"); + static bool ValidateCacheNumshardbits(const char* flagname, int32_t value) { if (value >= 20) { fprintf(stderr, "Invalid value for --%s: %d, must be < 20\n", @@ -2199,6 +2202,17 @@ class Benchmark { std::shared_ptr timestamp_emulator_; }; + class KeepFilter : public CompactionFilter { + public: + virtual bool Filter(int /*level*/, const Slice& /*key*/, + const Slice& /*value*/, std::string* /*new_value*/, + bool* /*value_changed*/) const override { + return false; + } + + virtual const char* Name() const override { return "KeepFilter"; } + }; + std::shared_ptr NewCache(int64_t capacity) { if (capacity <= 0) { return nullptr; @@ -3427,6 +3441,12 @@ void VerifyDBFromDB(std::string& truth_db_name) { } options.wal_dir = wal_dir; } + + // KeepFilter is a noop filter, this can be used to test compaction filter + if (FLAGS_use_keep_filter) { + options.compaction_filter = new KeepFilter(); + fprintf(stdout, "A noop compaction filter is used\n"); + } } void Open(Options* opts) {