PragmaTwice commented on code in PR #2954:
URL: https://github.com/apache/kvrocks/pull/2954#discussion_r2106747978


##########
src/server/server.cc:
##########
@@ -2126,3 +2127,149 @@ AuthResult Server::AuthenticateUser(const std::string 
&user_password, std::strin
   *ns = kDefaultNamespace;
   return AuthResult::IS_ADMIN;
 }
+
+Status Server::GetSlotStats(const std::vector<SlotRange> &slot_ranges, 
std::vector<std::string> *v_stats) {
+  std::lock_guard<std::mutex> lg(db_job_mu_);
+  std::bitset<HASH_SLOTS_SIZE> checked_slots;
+  uint64_t total_keys = 0;
+  uint64_t total_unexpected_keys = 0;
+  for (auto slot_range : slot_ranges) {
+    for (int slot = slot_range.start; slot <= slot_range.end; slot++) {
+      if (checked_slots.test(slot)) {
+        continue;
+      } else {
+        checked_slots.set(slot);
+      }
+
+      if (slot_scan_infos_.slot_stats.find(slot) == 
slot_scan_infos_.slot_stats.end()) {
+        v_stats->emplace_back(fmt::format("slot: {}, keys: {}, unexpected 
keys: {}", slot, 0, 0));
+      } else {
+        SlotStats ss = slot_scan_infos_.slot_stats[slot];
+        v_stats->emplace_back(
+            fmt::format("slot: {}, keys: {}, unexpected keys: {}", slot, 
ss.n_key, ss.n_unexpected_key));

Review Comment:
   IMHO it should be in standard RESP format, e.g. `Map(slot: Integer(..), 
keys: Integer(..))` instead of such hand-written format.



-- 
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