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

[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #538: PSYNC based on Unique Replication Sequence ID

git-hulk commented on code in PR #538:
URL: https://github.com/apache/incubator-kvrocks/pull/538#discussion_r865886463


##########
src/server.cc:
##########
@@ -1422,3 +1412,24 @@ void Server::AdjustOpenFilesLimit() {
                  << " (it's originally set to " << old_limit << ")";
   }
 }
+
+std::string ServerLogData::Encode() {
+  if (type_ == kReplIdLog) {
+    return std::string(1, kReplIdTag) + " " + content_;
+  } else {
+    return content_;
+  }
+}
+
+Status ServerLogData::Decode(const rocksdb::Slice &blob) {
+  if (blob.size() == 0) {
+    return Status(Status::NotOK);
+  }
+
+  const char *header = blob.data();
+  if (*header == kReplIdTag) {
+    type_ = kReplIdLog;
+  }
+  content_ = std::string(blob.data()+2, blob.size()-2);

Review Comment:
   should check the blob data length before using it?



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

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