diff --git a/tools/ldb_cmd.cc b/tools/ldb_cmd.cc index f39b2aae963a..ee2a651d8f25 100644 --- a/tools/ldb_cmd.cc +++ b/tools/ldb_cmd.cc @@ -2876,6 +2876,8 @@ void GetCommand::DoCommand() { if (st.ok()) { fprintf(stdout, "%s\n", (is_value_hex_ ? StringToHex(value) : value).c_str()); + } else if (st.IsNotFound()) { + fprintf(stdout, "Key not found\n"); } else { std::stringstream oss; oss << "Get failed: " << st.ToString(); @@ -2906,7 +2908,6 @@ void MultiGetCommand::Help(std::string& ret) { ret.append(" "); ret.append(MultiGetCommand::Name()); ret.append(" ..."); - ret.append(" [--" + ARG_TTL + "]"); ret.append("\n"); } @@ -2928,8 +2929,12 @@ void MultiGetCommand::DoCommand() { bool failed = false; for (size_t i = 0; i < num_keys; ++i) { if (statuses[i].ok()) { - fprintf(stdout, is_value_hex_ ? "0x%s\n" : "%s\n", + fprintf(stdout, is_value_hex_ ? "%s%s0x%s\n" : "%s%s%s\n", + (is_key_hex_ ? StringToHex(keys_[i]) : keys_[i]).c_str(), DELIM, values[i].ToString(is_value_hex_).c_str()); + } else if (statuses[i].IsNotFound()) { + fprintf(stdout, "Key not found: %s\n", + (is_key_hex_ ? StringToHex(keys_[i]) : keys_[i]).c_str()); } else { fprintf(stderr, "Status for key %s: %s\n", (is_key_hex_ ? StringToHex(keys_[i]) : keys_[i]).c_str(), diff --git a/tools/ldb_test.py b/tools/ldb_test.py index cde0414713d1..0d6b125f0274 100644 --- a/tools/ldb_test.py +++ b/tools/ldb_test.py @@ -119,7 +119,9 @@ def testSimpleStringPutGet(self): self.assertRunOK("put x2 y2", "OK") self.assertRunOK("get x1", "y1") self.assertRunOK("get x2", "y2") - self.assertRunFAIL("get x3") + self.assertRunOK("multi_get x1 x2", "x1 ==> y1\nx2 ==> y2") + self.assertRunOK("get x3", "Key not found") + self.assertRunOK("multi_get x3", "Key not found: x3") self.assertRunFAIL("put_entity x4") self.assertRunFAIL("put_entity x4 cv1") @@ -311,6 +313,8 @@ def testHexPutGet(self): self.assertRunOK("get --hex 0x6131", "0x6231") self.assertRunOK("get a2", "b2") self.assertRunOK("get --hex 0x6132", "0x6232") + self.assertRunOK("multi_get --hex 0x6131 0x6132", "0x6131 ==> 0x6231\n0x6132 ==> 0x6232") + self.assertRunOK("multi_get --hex 0x6131 0xBEEF", "0x6131 ==> 0x6231\nKey not found: 0xBEEF") self.assertRunOK("get --key_hex 0x6132", "b2") self.assertRunOK("get --key_hex --value_hex 0x6132", "0x6232") self.assertRunOK("get --value_hex a2", "0x6232") diff --git a/tools/ldb_tool.cc b/tools/ldb_tool.cc index a7aebc121dc8..45f603dcfbd2 100644 --- a/tools/ldb_tool.cc +++ b/tools/ldb_tool.cc @@ -5,6 +5,7 @@ // #include "rocksdb/ldb_tool.h" +#include "ldb_cmd_impl.h" #include "rocksdb/utilities/ldb_cmd.h" #include "tools/ldb_cmd_impl.h" @@ -90,6 +91,7 @@ void LDBCommandRunner::PrintHelp(const LDBOptions& ldb_options, ret.append("Data Access Commands:\n"); PutCommand::Help(ret); GetCommand::Help(ret); + MultiGetCommand::Help(ret); BatchPutCommand::Help(ret); ScanCommand::Help(ret); DeleteCommand::Help(ret);