Skip to content

Commit

Permalink
tools: Append bloom_bits to filter_uri as an argument if specified (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-io committed Oct 3, 2022
1 parent 13b992a commit 2285501
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
15 changes: 8 additions & 7 deletions db_stress_tool/db_stress_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ std::shared_ptr<const FilterPolicy> CreateFilterPolicy() {
ConfigOptions config_options;
std::shared_ptr<const FilterPolicy> 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;
Expand Down
15 changes: 9 additions & 6 deletions tools/db_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2285501

Please sign in to comment.