mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 16:30:56 +00:00
Deserialize custom Statistics object in db_bench
Summary: Added -statistics_string to deserialize a Statistics object using the factory functions registered by applications. Closes https://github.com/facebook/rocksdb/pull/1812 Differential Revision: D4469811 Pulled By: ajkr fbshipit-source-id: 2d80862
This commit is contained in:
parent
3b35134e4b
commit
37d4a79e99
|
@ -459,6 +459,7 @@ DEFINE_bool(verify_checksum, false, "Verify checksum for every block read"
|
|||
" from storage");
|
||||
|
||||
DEFINE_bool(statistics, false, "Database statistics");
|
||||
DEFINE_string(statistics_string, "", "Serialized statistics string");
|
||||
static class std::shared_ptr<rocksdb::Statistics> dbstats;
|
||||
|
||||
DEFINE_int64(writes, -1, "Number of write operations to do. If negative, do"
|
||||
|
@ -4878,6 +4879,24 @@ int db_bench_tool(int argc, char** argv) {
|
|||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
FLAGS_compaction_style_e = (rocksdb::CompactionStyle) FLAGS_compaction_style;
|
||||
#ifndef ROCKSDB_LITE
|
||||
if (FLAGS_statistics && !FLAGS_statistics_string.empty()) {
|
||||
fprintf(stderr,
|
||||
"Cannot provide both --statistics and --statistics_string.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!FLAGS_statistics_string.empty()) {
|
||||
std::unique_ptr<Statistics> custom_stats_guard;
|
||||
dbstats.reset(NewCustomObject<Statistics>(FLAGS_statistics_string,
|
||||
&custom_stats_guard));
|
||||
custom_stats_guard.release();
|
||||
if (dbstats == nullptr) {
|
||||
fprintf(stderr, "No Statistics registered matching string: %s\n",
|
||||
FLAGS_statistics_string.c_str());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif // ROCKSDB_LITE
|
||||
if (FLAGS_statistics) {
|
||||
dbstats = rocksdb::CreateDBStatistics();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue