jihuayu commented on code in PR #2242:
URL: https://github.com/apache/kvrocks/pull/2242#discussion_r1564319475


##########
src/server/server.cc:
##########
@@ -846,13 +846,18 @@ void Server::GetRocksDBInfo(std::string *info) {
   db->GetAggregatedIntProperty("rocksdb.num-live-versions", 
&num_live_versions);
 
   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 cf_handle = storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
+  db->GetIntProperty(cf_handle, "rocksdb.block-cache-usage", 
&block_cache_usage);
+  string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
+
   for (const auto &cf_handle : *storage->GetCFHandles()) {

Review Comment:
   Hi, sonar Cloud telling us we declaration shadows a local variable is not 
clear. 
   Can you change the variable name?
   
https://sonarcloud.io/project/issues?open=AY7Xa5ShOhsi8ezKPlra&id=apache_kvrocks



##########
src/server/server.cc:
##########
@@ -846,13 +846,18 @@ void Server::GetRocksDBInfo(std::string *info) {
   db->GetAggregatedIntProperty("rocksdb.num-live-versions", 
&num_live_versions);
 
   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 cf_handle = storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
+  db->GetIntProperty(cf_handle, "rocksdb.block-cache-usage", 
&block_cache_usage);
+  string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
+
   for (const auto &cf_handle : *storage->GetCFHandles()) {
-    uint64_t estimate_keys = 0, block_cache_usage = 0, 
block_cache_pinned_usage = 0, index_and_filter_cache_usage = 0;
+    uint64_t estimate_keys = 0, block_cache_pinned_usage = 0, 
index_and_filter_cache_usage = 0;

Review Comment:
   Can you split each identifier in a dedicated statement
   ```suggestion
       uint64_t estimate_keys = 0;
       uint64_t block_cache_pinned_usage = 0;
       uint64_t index_and_filter_cache_usage = 0;
   ```
   
https://sonarcloud.io/project/issues?open=AY7Xa5ShOhsi8ezKPlrb&id=apache_kvrocks



##########
src/server/server.cc:
##########
@@ -846,13 +846,18 @@ void Server::GetRocksDBInfo(std::string *info) {
   db->GetAggregatedIntProperty("rocksdb.num-live-versions", 
&num_live_versions);
 
   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 cf_handle = storage->GetCFHandle(engine::kSubkeyColumnFamilyName);
+  db->GetIntProperty(cf_handle, "rocksdb.block-cache-usage", 
&block_cache_usage);
+  string_stream << "block_cache_usage:" << block_cache_usage << "\r\n";
+
   for (const auto &cf_handle : *storage->GetCFHandles()) {

Review Comment:
   Hi, sonar cloud telling us we declaration shadows a local variable is not 
clear. 
   Can you change the variable name?
   
https://sonarcloud.io/project/issues?open=AY7Xa5ShOhsi8ezKPlra&id=apache_kvrocks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to