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


##########
src/types/redis_bloom_chain.cc:
##########
@@ -195,4 +195,44 @@ rocksdb::Status BloomChain::Exist(const Slice &user_key, 
const Slice &item, int
 
   return rocksdb::Status::OK();
 }
+
+rocksdb::Status BloomChain::Info(const Slice &user_key, const BloomInfoType 
&type, std::vector<int> *rets) {
+  std::string ns_key = AppendNamespacePrefix(user_key);
+  LockGuard guard(storage_->GetLockManager(), ns_key);
+
+  BloomChainMetadata metadata;
+  rocksdb::Status s = getBloomChainMetadata(ns_key, &metadata);
+  if (s.IsNotFound()) return rocksdb::Status::NotFound("key is not found");
+  if (!s.ok()) return s;
+
+  switch (type) {
+    case ALL:
+      rets->push_back(static_cast<int>(metadata.GetCapacity()));
+      rets->push_back(static_cast<int>(metadata.bloom_bytes));
+      rets->push_back(static_cast<int>(metadata.n_filters));
+      rets->push_back(static_cast<int>(metadata.size));
+      rets->push_back(static_cast<int>(metadata.expansion));
+      break;
+    case CAPACITY:
+      rets->push_back(static_cast<int>(metadata.GetCapacity()));
+      break;
+    case SIZE:
+      rets->push_back(static_cast<int>(metadata.bloom_bytes));
+      break;
+    case FILTERS:
+      rets->push_back(static_cast<int>(metadata.n_filters));
+      break;
+    case ITEMS:
+      rets->push_back(static_cast<int>(metadata.size));
+      break;
+    case EXPANSION:
+      rets->push_back(static_cast<int>(metadata.expansion));
+      break;

Review Comment:
   I think maybe we can just return a structure here, e.g.
   ```
   struct BloomFilterInfo {
       cap, bytes, ...;
   };
   
   Info(..., BloomFilterInfo *info) {
      ...
      info->... = ...;
   }
   ```
   
   And move the switch case to the command execute function.



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