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


##########
src/server/server.cc:
##########
@@ -2126,3 +2127,123 @@ 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));
+        total_keys += ss.n_key;
+        total_unexpected_keys += ss.n_unexpected_key;
+      }
+    }
+  }
+  v_stats->emplace_back(fmt::format("total keys: {}, total unexpected keys: 
{}", total_keys, total_unexpected_keys));
+  return Status::OK();
+}
+
+Status Server::AsyncScanSlots(const std::string &ns, const 
std::vector<SlotRange> &slot_ranges) {

Review Comment:
   convert to draft, wait for a moment.



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