Skip to content

Commit

Permalink
get secondary_path as a permanent argument and some other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Or Friedmann committed Mar 15, 2023
1 parent 8da2a5a commit a469d0d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/rocksdb/utilities/ldb_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class LDBCommand {
static const std::string ARG_DECODE_BLOB_INDEX;
static const std::string ARG_DUMP_UNCOMPRESSED_BLOBS;
static const std::string ARG_INTERACTIVE;
static const std::string ARG_KEYS_ONLY;

struct ParsedParams {
std::string cmd;
std::vector<std::string> cmd_params;
Expand Down
1 change: 1 addition & 0 deletions monitoring/histogram_windowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HistogramWindowingImpl : public Histogram
virtual uint64_t min() const override { return stats_.min(); }
virtual uint64_t max() const override { return stats_.max(); }
virtual uint64_t num() const override { return stats_.num(); }
virtual uint64_t sum() const override { return stats_.sum(); }
virtual double Median() const override;
virtual double Percentile(double p) const override;
virtual double Average() const override;
Expand Down
45 changes: 32 additions & 13 deletions tools/beezcli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,34 @@ int main(int argc, char** argv) {
signal(SIGINT, &SignalHandler);
ROCKSDB_NAMESPACE::LDBTool tool;
std::string prompt = "beezcli> ";
const char* const short_opts = "di\0";
const option long_opts[] = {
{"db", required_argument, 0 ,'d'},
{"interactive", no_argument, nullptr, 'i'},
{0, 0, 0, 0}
};
const char* const short_opts = "dis\0";
const option long_opts[] = {{"db", required_argument, 0, 'd'},
{"interactive", no_argument, nullptr, 'i'},
{"secondary_path", required_argument, 0, 's'},
{"read_only", no_argument, 0, 'r'},
{0, 0, 0, 0}};
int opt;
std::string dbpath = "";
std::string db_path = "";
std::string secondary_path = "";
bool i = false;
bool d = false;
bool s [[maybe_unused]] = false;
opterr = 0;
opt = getopt_long(argc, argv, short_opts, long_opts, nullptr);
while (opt != -1) {
switch (opt) {
case 'd':
dbpath = std::string(optarg);
std::cout << dbpath << std::endl;
d = true;
break;
db_path = std::string(optarg);
std::cout << db_path << std::endl;
d = true;
break;
case 'i':
i = true;
break;
case 's':
secondary_path = std::string(optarg);
s = true;
break;
}
opt = getopt_long(argc, argv, short_opts, long_opts, nullptr);
}
Expand All @@ -69,16 +75,29 @@ int main(int argc, char** argv) {
SignalHandler(0);
}
if (!input.empty()) {
if (!s) {
std::vector<std::string> vec;
ToArgv(std::string(argv[0]) + " " + input + " --db=" + db_path,
vec);
std::vector<char*> cstrings{};
for (const auto& string : vec) {
cstrings.push_back(const_cast<char*>(string.c_str()));
}
tool.Run(cstrings.size(), cstrings.data());
} else {
std::vector<std::string> vec;
ToArgv(std::string(argv[0]) + " " + input + " --db=" + dbpath,vec);
ToArgv(std::string(argv[0]) + " " + input + " --db=" + db_path +
" --secondary_path=" + secondary_path,
vec);
std::vector<char*> cstrings{};
for(const auto& string : vec) {
cstrings.push_back(const_cast<char *>(string.c_str()));
}
tool.Run(cstrings.size(), cstrings.data());
}
}
}
if (line == NULL && i && d) {
if (line == nullptr && i && d) {
SignalHandler(0);
}
tool.Run(argc, argv);
Expand Down
27 changes: 16 additions & 11 deletions tools/ldb_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ const std::string LDBCommand::ARG_DECODE_BLOB_INDEX = "decode_blob_index";
const std::string LDBCommand::ARG_DUMP_UNCOMPRESSED_BLOBS =
"dump_uncompressed_blobs";
const std::string LDBCommand::ARG_INTERACTIVE = "interactive";
const std::string LDBCommand::ARG_KEYS_ONLY = "keys_only";

const char* LDBCommand::DELIM = " ==> ";

Expand Down Expand Up @@ -1112,7 +1111,7 @@ std::string LDBCommand::HelpRangeCmdArgs() {
str_stream << " ";
str_stream << "[--" << ARG_FROM << "] ";
str_stream << "[--" << ARG_TO << "] ";
str_stream << "[--" << ARG_TTL << "] ";
str_stream << "[--" << ARG_TTL << "[=<ttl>]] ";
return str_stream.str();
}

Expand Down Expand Up @@ -1975,10 +1974,11 @@ DBDumperCommand::DBDumperCommand(
: LDBCommand(
options, flags, true,
BuildCmdLineOptions(
{ARG_TTL, ARG_SKIP_EXPIRED_DATA, ARG_KEYS_ONLY, ARG_HEX, ARG_KEY_HEX, ARG_VALUE_HEX, ARG_FROM, ARG_TO,
ARG_MAX_KEYS, ARG_COUNT_ONLY, ARG_COUNT_DELIM, ARG_STATS,
ARG_TTL_START, ARG_TTL_END, ARG_TTL_BUCKET, ARG_TIMESTAMP,
ARG_PATH, ARG_DECODE_BLOB_INDEX, ARG_DUMP_UNCOMPRESSED_BLOBS})),
{ARG_TTL, ARG_SKIP_EXPIRED_DATA, ARG_HEX, ARG_KEY_HEX,
ARG_VALUE_HEX, ARG_NO_VALUE, ARG_FROM, ARG_TO, ARG_MAX_KEYS,
ARG_COUNT_ONLY, ARG_COUNT_DELIM, ARG_STATS, ARG_TTL_START,
ARG_TTL_END, ARG_TTL_BUCKET, ARG_TIMESTAMP, ARG_PATH,
ARG_DECODE_BLOB_INDEX, ARG_DUMP_UNCOMPRESSED_BLOBS})),
null_from_(true),
null_to_(true),
max_keys_(-1),
Expand Down Expand Up @@ -2244,10 +2244,16 @@ void DBDumperCommand::DoDumpCommand() {
if (is_db_ttl_ && timestamp_) {
fprintf(stdout, "%s ", TimeToHumanString(rawtime).c_str());
}
std::string str =
PrintKeyValue(iter->key().ToString(), iter->value().ToString(),
is_key_hex_, is_value_hex_);
fprintf(stdout, "%s\n", str.c_str());
if (is_no_value_) {
std::string str = is_key_hex_ ? StringToHex(iter->key().ToString())
: iter->key().ToString();
fprintf(stdout, "%s\n", str.c_str());
} else {
std::string str =
PrintKeyValue(iter->key().ToString(), iter->value().ToString(),
is_key_hex_, is_value_hex_);
fprintf(stdout, "%s\n", str.c_str());
}
}
}

Expand Down Expand Up @@ -3088,7 +3094,6 @@ void ScanCommand::Help(std::string& ret) {
ret.append(" ");
ret.append(ScanCommand::Name());
ret.append(HelpRangeCmdArgs());
ret.append(" [--" + ARG_TTL + "[=<ttl>]]");
ret.append(" [--" + ARG_SKIP_EXPIRED_DATA + "]");
ret.append(" [--" + ARG_TIMESTAMP + "]");
ret.append(" [--" + ARG_MAX_KEYS + "=<N>q] ");
Expand Down

0 comments on commit a469d0d

Please sign in to comment.