PragmaTwice commented on code in PR #2954:
URL: https://github.com/apache/kvrocks/pull/2954#discussion_r2110756898
##########
src/server/server.cc:
##########
@@ -2126,3 +2127,107 @@ AuthResult Server::AuthenticateUser(const std::string
&user_password, std::strin
*ns = kDefaultNamespace;
return AuthResult::IS_ADMIN;
}
+
+std::string Server::GetSlotStats(const std::vector<SlotRange> &slot_ranges) {
+ size_t n = 0;
+ std::string output;
+
+ std::lock_guard<std::mutex> lg(db_job_mu_);
+ std::bitset<HASH_SLOTS_SIZE> checked_slots;
+ std::string slotstats;
+ 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);
+ }
+
+ ++n;
+ std::string slotstat;
+ slotstat.append(redis::MultiLen(3));
+ slotstat.append(redis::Integer(slot));
+ if (slot_scan_infos_.slot_stats.find(slot) ==
slot_scan_infos_.slot_stats.end()) {
+ slotstat.append(redis::Integer(0));
+ slotstat.append(redis::Integer(0));
+ } else {
+ SlotStats ss = slot_scan_infos_.slot_stats[slot];
+ slotstat.append(redis::Integer(ss.n_key));
+ slotstat.append(redis::Integer(ss.n_unexpected_key));
+ }
+ slotstats.append(slotstat);
Review Comment:
please use `Map` or attach attribute name for each field, otherwise users
don't know what's the meaning of these 3 integers.
--
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]