ldb dump can print histogram of value size

Summary:
Make "ldb dump --count_only" print histogram of value size. Also, fix a bug that "ldb dump --path=<db_path>" doesn't work.
Closes https://github.com/facebook/rocksdb/pull/2944

Differential Revision: D5954527

Pulled By: siying

fbshipit-source-id: c620a444ec544258b8d113f5f663c375dd53d6be
main
Siying Dong 7 years ago committed by Facebook Github Bot
parent 593d3de371
commit 2a3363d52e
  1. 14
      tools/ldb_cmd.cc

@ -1353,6 +1353,9 @@ DBDumperCommand::DBDumperCommand(
itr = options.find(ARG_PATH);
if (itr != options.end()) {
path_ = itr->second;
if (db_path_.empty()) {
db_path_ = path_;
}
}
}
@ -1485,6 +1488,8 @@ void DBDumperCommand::DoDumpCommand() {
ReadableTime(ttl_start).c_str(), ReadableTime(ttl_end).c_str());
}
HistogramImpl vsize_hist;
for (; iter->Valid(); iter->Next()) {
int rawtime = 0;
// If end marker was specified, we stop before it
@ -1529,7 +1534,9 @@ void DBDumperCommand::DoDumpCommand() {
}
if (count_only_) {
vsize_hist.Add(iter->value().size());
}
if (!count_only_ && !count_delim_) {
if (is_db_ttl_ && timestamp_) {
@ -1551,6 +1558,11 @@ void DBDumperCommand::DoDumpCommand() {
} else {
fprintf(stdout, "Keys in range: %lld\n", (long long) count);
}
if (count_only_) {
fprintf(stdout, "Value size distribution: \n");
fprintf(stdout, "%s\n", vsize_hist.ToString().c_str());
}
// Clean up
delete iter;
}

Loading…
Cancel
Save