diff --git a/README.md b/README.md index 312632dce..1877dbaaf 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,11 @@ You will see the following result if successful: Run tools to get all values that have been set: - bazel-bin/service/tools/kv/api_tools/kv_service_tools service/tools/config/interface/service.config getvalues + bazel-bin/service/tools/kv/api_tools/kv_service_tools service/tools/config/interface/service.config getallvalues You will see the following result if successful: - client getvalues value = [test_value] + client getallvalues value = [test_value] ## Deployment Script diff --git a/chain/state/chain_state_test.cpp b/chain/state/chain_state_test.cpp index 0d0fda1e4..ed745a4ac 100644 --- a/chain/state/chain_state_test.cpp +++ b/chain/state/chain_state_test.cpp @@ -38,7 +38,7 @@ TEST(KVServerExecutorTest, SetValue) { EXPECT_EQ(state.SetValue("test_key", "test_value"), 0); EXPECT_EQ(state.GetValue("test_key"), "test_value"); - // GetValues and GetRange may be out of order for in-memory, so we test up to + // GetAllValues and GetRange may be out of order for in-memory, so we test up to // 1 key-value pair EXPECT_EQ(state.GetAllValues(), "[test_value]"); EXPECT_EQ(state.GetRange("a", "z"), "[test_value]"); diff --git a/executor/kv/kv_executor.cpp b/executor/kv/kv_executor.cpp index 8d2ecf557..e3ca4b698 100644 --- a/executor/kv/kv_executor.cpp +++ b/executor/kv/kv_executor.cpp @@ -48,8 +48,8 @@ std::unique_ptr KVExecutor::ExecuteData( Set(kv_request.key(), kv_request.value()); } else if (kv_request.cmd() == KVRequest::GET) { kv_response.set_value(Get(kv_request.key())); - } else if (kv_request.cmd() == KVRequest::GETVALUES) { - kv_response.set_value(GetValues()); + } else if (kv_request.cmd() == KVRequest::GETALLVALUES) { + kv_response.set_value(GetAllValues()); } else if (kv_request.cmd() == KVRequest::GETRANGE) { kv_response.set_value(GetRange(kv_request.key(), kv_request.value())); } @@ -70,7 +70,7 @@ std::string KVExecutor::Get(const std::string& key) { return state_->GetValue(key); } -std::string KVExecutor::GetValues() { return state_->GetAllValues(); } +std::string KVExecutor::GetAllValues() { return state_->GetAllValues(); } // Get values on a range of keys std::string KVExecutor::GetRange(const std::string& min_key, diff --git a/executor/kv/kv_executor.h b/executor/kv/kv_executor.h index 58392f03f..c9ba010b1 100644 --- a/executor/kv/kv_executor.h +++ b/executor/kv/kv_executor.h @@ -45,7 +45,7 @@ class KVExecutor : public TransactionManager { protected: virtual void Set(const std::string& key, const std::string& value); std::string Get(const std::string& key); - std::string GetValues(); + std::string GetAllValues(); std::string GetRange(const std::string& min_key, const std::string& max_key); private: diff --git a/executor/kv/kv_executor_test.cpp b/executor/kv/kv_executor_test.cpp index 17b32a46b..fefc432e1 100644 --- a/executor/kv/kv_executor_test.cpp +++ b/executor/kv/kv_executor_test.cpp @@ -83,9 +83,9 @@ class KVExecutorTest : public Test { return kv_response.value(); } - std::string GetValues() { + std::string GetAllValues() { KVRequest request; - request.set_cmd(KVRequest::GETVALUES); + request.set_cmd(KVRequest::GETALLVALUES); std::string str; if (!request.SerializeToString(&str)) { @@ -152,13 +152,13 @@ TEST_F(KVExecutorTest, SetValue) { EXPECT_CALL(*mock_storage_ptr_, GetRange("a", "z")) .WillOnce(Return("[test_value]")); - EXPECT_EQ(GetValues(), "[]"); + EXPECT_EQ(GetAllValues(), "[]"); EXPECT_EQ(Set("test_key", "test_value"), 0); EXPECT_EQ(Get("test_key"), "test_value"); - // GetValues and GetRange may be out of order for in-memory, so we test up to + // GetAllValues and GetRange may be out of order for in-memory, so we test up to // 1 key-value pair - EXPECT_EQ(GetValues(), "[test_value]"); + EXPECT_EQ(GetAllValues(), "[test_value]"); EXPECT_EQ(GetRange("a", "z"), "[test_value]"); } diff --git a/interface/kv/kv_client.cpp b/interface/kv/kv_client.cpp index e3a3e7e48..53a304ef5 100644 --- a/interface/kv/kv_client.cpp +++ b/interface/kv/kv_client.cpp @@ -55,9 +55,9 @@ std::unique_ptr KVClient::Get(const std::string& key) { return std::make_unique(response.value()); } -std::unique_ptr KVClient::GetValues() { +std::unique_ptr KVClient::GetAllValues() { KVRequest request; - request.set_cmd(KVRequest::GETVALUES); + request.set_cmd(KVRequest::GETALLVALUES); KVResponse response; int ret = SendRequest(request, &response); if (ret != 0) { diff --git a/interface/kv/kv_client.h b/interface/kv/kv_client.h index 03724d380..87c4a00d0 100644 --- a/interface/kv/kv_client.h +++ b/interface/kv/kv_client.h @@ -36,7 +36,7 @@ class KVClient : public TransactionConstructor { int Set(const std::string& key, const std::string& data); std::unique_ptr Get(const std::string& key); - std::unique_ptr GetValues(); + std::unique_ptr GetAllValues(); std::unique_ptr GetRange(const std::string& min_key, const std::string& max_key); }; diff --git a/proto/kv/kv.proto b/proto/kv/kv.proto index ce0d1d260..9cfb4a64b 100644 --- a/proto/kv/kv.proto +++ b/proto/kv/kv.proto @@ -7,7 +7,7 @@ message KVRequest { NONE = 0; SET = 1; GET = 2; - GETVALUES = 3; + GETALLVALUES = 3; GETRANGE = 4; } CMD cmd = 1; diff --git a/service/tools/kv/api_tools/kv_service_tools.cpp b/service/tools/kv/api_tools/kv_service_tools.cpp index f461e42c5..4cddb2bee 100644 --- a/service/tools/kv/api_tools/kv_service_tools.cpp +++ b/service/tools/kv/api_tools/kv_service_tools.cpp @@ -43,14 +43,14 @@ using resdb::ResDBConfig; int main(int argc, char** argv) { if (argc < 3) { printf( - " (set/get/getvalues/getrange), [key] " + " (set/get/getallvalues/getrange), [key] " "[value/key2]\n"); return 0; } std::string client_config_file = argv[1]; std::string cmd = argv[2]; std::string key; - if (cmd != "getvalues") { + if (cmd != "getallvalues") { key = argv[3]; } std::string value; @@ -79,12 +79,12 @@ int main(int argc, char** argv) { } else { printf("client get value fail\n"); } - } else if (cmd == "getvalues") { - auto res = client.GetValues(); + } else if (cmd == "getallvalues") { + auto res = client.GetAllValues(); if (res != nullptr) { - printf("client getvalues value = %s\n", res->c_str()); + printf("client getallvalues value = %s\n", res->c_str()); } else { - printf("client getvalues value fail\n"); + printf("client getallvalues value fail\n"); } } else if (cmd == "getrange") { auto res = client.GetRange(key, key2);