This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 0e2273aa Minor code style enhancement for src/server (#2264)
0e2273aa is described below

commit 0e2273aa282e8b0c44f5e37cc78609c7e94ac433
Author: mwish <[email protected]>
AuthorDate: Mon Apr 22 17:54:54 2024 +0800

    Minor code style enhancement for src/server (#2264)
---
 src/server/redis_connection.cc | 11 ++++++-----
 src/server/server.cc           | 23 +++++++++++++----------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/server/redis_connection.cc b/src/server/redis_connection.cc
index 19bcbceb..a470f225 100644
--- a/src/server/redis_connection.cc
+++ b/src/server/redis_connection.cc
@@ -409,18 +409,19 @@ Status Connection::ExecuteCommand(const std::string 
&cmd_name, const std::vector
 }
 
 void Connection::ExecuteCommands(std::deque<CommandTokens> *to_process_cmds) {
-  Config *config = srv_->GetConfig();
-  std::string reply, password = config->requirepass;
+  const Config *config = srv_->GetConfig();
+  std::string reply;
+  std::string password = config->requirepass;
 
   while (!to_process_cmds->empty()) {
-    auto cmd_tokens = to_process_cmds->front();
+    CommandTokens cmd_tokens = std::move(to_process_cmds->front());
     to_process_cmds->pop_front();
     if (cmd_tokens.empty()) continue;
 
     bool is_multi_exec = IsFlagEnabled(Connection::kMultiExec);
     if (IsFlagEnabled(redis::Connection::kCloseAfterReply) && !is_multi_exec) 
break;
 
-    auto cmd_s = srv_->LookupAndCreateCommand(cmd_tokens.front());
+    auto cmd_s = Server::LookupAndCreateCommand(cmd_tokens.front());
     if (!cmd_s.IsOK()) {
       if (is_multi_exec) multi_error_ = true;
       Reply(redis::Error("ERR unknown command " + cmd_tokens.front()));
@@ -428,7 +429,7 @@ void Connection::ExecuteCommands(std::deque<CommandTokens> 
*to_process_cmds) {
     }
     auto current_cmd = std::move(*cmd_s);
 
-    const auto attributes = current_cmd->GetAttributes();
+    const auto &attributes = current_cmd->GetAttributes();
     auto cmd_name = attributes->name;
     auto cmd_flags = attributes->GenerateFlags(cmd_tokens);
 
diff --git a/src/server/server.cc b/src/server/server.cc
index f131bccd..9408b90c 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -847,22 +847,25 @@ void Server::GetRocksDBInfo(std::string *info) {
 
   string_stream << "# RocksDB\r\n";
 
-  uint64_t block_cache_usage = 0;
-  // All column families share the same block cache, so it's good to count a 
single one.
-  auto subkey_cf_handle = 
storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
-  db->GetIntProperty(subkey_cf_handle, "rocksdb.block-cache-usage", 
&block_cache_usage);
-  string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
+  {
+    // All column families share the same block cache, so it's good to count a 
single one.
+    uint64_t block_cache_usage = 0;
+    uint64_t block_cache_pinned_usage = 0;
+    auto subkey_cf_handle = 
storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
+    db->GetIntProperty(subkey_cf_handle, 
rocksdb::DB::Properties::kBlockCacheUsage, &block_cache_usage);
+    string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
+    db->GetIntProperty(subkey_cf_handle, 
rocksdb::DB::Properties::kBlockCachePinnedUsage, &block_cache_pinned_usage);
+    string_stream << "block_cache_pinned_usage[" << 
subkey_cf_handle->GetName() << "]:" << block_cache_pinned_usage
+                  << "\r\n";
+  }
 
   for (const auto &cf_handle : *storage->GetCFHandles()) {
     uint64_t estimate_keys = 0;
-    uint64_t block_cache_pinned_usage = 0;
     uint64_t index_and_filter_cache_usage = 0;
     std::map<std::string, std::string> cf_stats_map;
-    db->GetIntProperty(cf_handle, "rocksdb.estimate-num-keys", &estimate_keys);
+    db->GetIntProperty(cf_handle, rocksdb::DB::Properties::kEstimateNumKeys, 
&estimate_keys);
     string_stream << "estimate_keys[" << cf_handle->GetName() << "]:" << 
estimate_keys << "\r\n";
-    db->GetIntProperty(cf_handle, "rocksdb.block-cache-pinned-usage", 
&block_cache_pinned_usage);
-    string_stream << "block_cache_pinned_usage[" << cf_handle->GetName() << 
"]:" << block_cache_pinned_usage << "\r\n";
-    db->GetIntProperty(cf_handle, "rocksdb.estimate-table-readers-mem", 
&index_and_filter_cache_usage);
+    db->GetIntProperty(cf_handle, 
rocksdb::DB::Properties::kEstimateTableReadersMem, 
&index_and_filter_cache_usage);
     string_stream << "index_and_filter_cache_usage[" << cf_handle->GetName() 
<< "]:" << index_and_filter_cache_usage
                   << "\r\n";
     db->GetMapProperty(cf_handle, rocksdb::DB::Properties::kCFStats, 
&cf_stats_map);

Reply via email to