git-hulk commented on code in PR #1703:
URL: https://github.com/apache/kvrocks/pull/1703#discussion_r1305592953


##########
src/storage/table_properties_collector.cc:
##########
@@ -47,23 +43,18 @@ rocksdb::Status CompactOnExpiredCollector::AddUserKey(const 
rocksdb::Slice &key,
   if (cf_name_ != "metadata") {
     return rocksdb::Status::OK();
   }
-  rocksdb::Slice cv = value;
-  if (entry_type != rocksdb::kEntryPut || cv.size() < 5) {
+
+  if (entry_type != rocksdb::kEntryPut || value.size() < 5) {
     return rocksdb::Status::OK();
   }
-  GetFixed8(&cv, &type);
-  GetFixed32(&cv, &expired);
-  type = type & (uint8_t)0x0f;
-  if (type == kRedisBitmap || type == kRedisSet || type == kRedisList || type 
== kRedisHash || type == kRedisZSet ||
-      type == kRedisSortedint) {
-    if (cv.size() <= 12) return rocksdb::Status::OK();
-    GetFixed64(&cv, &version);
-    GetFixed32(&cv, &subkeys);
-  }
-  total_keys_ += subkeys;
-  int now = Server::GetCachedUnixTime();
-  if ((expired > 0 && expired < static_cast<uint32_t>(now)) || (type != 
kRedisString && subkeys == 0)) {
-    deleted_keys_ += subkeys + 1;
+
+  Metadata metadata(RedisType::kRedisNone);
+  auto s = metadata.Decode(value);
+  if (!s.ok()) return rocksdb::Status::OK();
+
+  total_keys_ += metadata.size;

Review Comment:
   For string type, its size means the length of the string, so should only 
increase 1  for total and delete keys.



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