torwig commented on code in PR #2402:
URL: https://github.com/apache/kvrocks/pull/2402#discussion_r1677100528
##########
src/types/redis_hash.cc:
##########
@@ -45,7 +46,13 @@ rocksdb::Status Hash::Size(const Slice &user_key, uint64_t
*size) {
HashMetadata metadata(false);
rocksdb::Status s = GetMetadata(Database::GetOptions{}, ns_key, &metadata);
if (!s.ok()) return s;
- *size = metadata.size;
+ if (!metadata.IsEncodedFieldExpire()) {
+ *size = metadata.size;
+ } else {
+ std::vector<FieldValue> field_values;
+ GetAll(user_key, &field_values, HashFetchType::kOnlyKey);
Review Comment:
Would it be more effective to **count** available keys (a dedicated
function) instead of loading them into memory and getting their size? If we
have millions of elements, for example.
--
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]