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


##########
src/types/redis_stream.cc:
##########
@@ -232,6 +241,35 @@ std::string 
Stream::encodeStreamConsumerMetadataValue(const StreamConsumerMetada
   return dst;
 }
 
+StreamConsumerMetadata Stream::decodeStreamConsumerMetadataValue(const 
std::string &value) {
+  StreamConsumerMetadata consumer_metadata;
+  rocksdb::Slice input(value);
+  GetFixed64(&input, &consumer_metadata.pending_number);
+  GetFixed64(&input, &consumer_metadata.last_idle);
+  GetFixed64(&input, &consumer_metadata.last_active);
+  return consumer_metadata;
+}
+
+StreamSubkeyType Stream::identifySubkeyType(const rocksdb::Slice &key) {
+  InternalKey ikey(key, storage_->IsSlotIdEncoded());
+  Slice subkey = ikey.GetSubKey();
+  const size_t entry_id_size = sizeof(StreamEntryID);
+  if (subkey.size() <= entry_id_size) {
+    return StreamSubkeyType::StreamEntry;
+  }
+  uint64_t group_name_len = 0;
+  GetFixed64(&subkey, &group_name_len);
+  std::string without_group_name = subkey.ToString().substr(group_name_len);
+  const size_t metadata_delimiter_size = 
strlen(consumerGroupMetadataDelimiter);

Review Comment:
   You can make `consumerGroupMetadataDelimiter` a `string_view` and then 
remove this `strlen`.



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