From 228550186908ff10abddba5c1f698669a5913306 Mon Sep 17 00:00:00 2001 From: Isaac Garzon Date: Mon, 3 Oct 2022 11:07:40 +0300 Subject: [PATCH] tools: Append bloom_bits to filter_uri as an argument if specified (#71) --- db_stress_tool/db_stress_test_base.cc | 15 ++++++++------- tools/db_bench_tool.cc | 15 +++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 3d7d15188d..8e1125853a 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -34,16 +34,17 @@ std::shared_ptr CreateFilterPolicy() { ConfigOptions config_options; std::shared_ptr policy; config_options.ignore_unsupported_options = false; + std::string bits_str; if (FLAGS_bloom_bits > 0) { - fprintf(stderr, - "--filter_uri and --bloom_bits are incompatible options\n"); - exit(1); + bits_str = ":" + FormatDoubleParam(FLAGS_bloom_bits); + fprintf(stderr, "note: appending --bloom-bits (%f) to --filter-uri\n", + FLAGS_bloom_bits); } - Status s = FilterPolicy::CreateFromString(config_options, FLAGS_filter_uri, - &policy); + Status s = FilterPolicy::CreateFromString( + config_options, FLAGS_filter_uri + bits_str, &policy); if (!s.ok() || !policy) { - fprintf(stderr, "Cannot create filter policy(%s): %s\n", - FLAGS_filter_uri.c_str(), s.ToString().c_str()); + fprintf(stderr, "Cannot create filter policy(%s%s): %s\n", + FLAGS_filter_uri.c_str(), bits_str.c_str(), s.ToString().c_str()); exit(1); } return policy; diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 874032d9fb..b3e0935b4a 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -4351,19 +4351,22 @@ class Benchmark { if (FLAGS_cache_size) { table_options->block_cache = cache_; } + std::string bits_str; if (FLAGS_bloom_bits > 0) { - fprintf(stderr, - "--filter_uri and --bloom_bits are incompatible options\n"); - exit(1); + bits_str = ":" + ROCKSDB_NAMESPACE::ToString(FLAGS_bloom_bits); + fprintf(stderr, "note: appending --bloom-bits (%f) to --filter-uri\n", + FLAGS_bloom_bits); } if (!FLAGS_filter_uri.empty()) { ConfigOptions config_options; config_options.ignore_unsupported_options = false; Status s = FilterPolicy::CreateFromString( - config_options, FLAGS_filter_uri, &table_options->filter_policy); + config_options, FLAGS_filter_uri + bits_str, + &table_options->filter_policy); if (!s.ok()) { - fprintf(stderr, "failure creating filter policy[%s]: %s\n", - FLAGS_filter_uri.c_str(), s.ToString().c_str()); + fprintf(stderr, "failure creating filter policy[%s%s]: %s\n", + FLAGS_filter_uri.c_str(), bits_str.c_str(), + s.ToString().c_str()); exit(1); } } else if (FLAGS_bloom_bits < 0) {