You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/08/13 14:43:03 UTC

[GitHub] [incubator-kvrocks] caipengbo commented on a diff in pull request #745: Add streams

caipengbo commented on code in PR #745:
URL: https://github.com/apache/incubator-kvrocks/pull/745#discussion_r945155879


##########
src/redis_metadata.cc:
##########
@@ -287,3 +289,65 @@ rocksdb::Status ListMetadata::Decode(const std::string &bytes) {
   }
   return rocksdb::Status::OK();
 }
+
+void StreamMetadata::Encode(std::string *dst) {
+  Metadata::Encode(dst);
+
+  PutFixed64(dst, last_generated_id.ms);
+  PutFixed64(dst, last_generated_id.seq);
+
+  PutFixed64(dst, recorded_first_entry_id.ms);
+  PutFixed64(dst, recorded_first_entry_id.seq);
+
+  PutFixed64(dst, max_deleted_entry_id.ms);
+  PutFixed64(dst, max_deleted_entry_id.seq);
+
+  PutFixed64(dst, first_entry_id.ms);
+  PutFixed64(dst, first_entry_id.seq);
+
+  PutFixed64(dst, last_entry_id.ms);
+  PutFixed64(dst, last_entry_id.seq);
+
+  PutFixed64(dst, entries_added);
+}
+
+rocksdb::Status StreamMetadata::Decode(const std::string &bytes) {
+  // flags(1byte) + expire (4byte)
+  if (bytes.size() < 5) {
+    return rocksdb::Status::InvalidArgument("the metadata is too short");

Review Comment:
   Would it be better if we extract `the metadata is too short` into a const variable? 
   I found a lot of the same strings in this file.



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org