xq2010 commented on code in PR #1798:
URL: https://github.com/apache/kvrocks/pull/1798#discussion_r1356051826


##########
src/storage/rdb.cc:
##########
@@ -39,53 +43,69 @@
 constexpr const int RDB6BitLen = 0;
 constexpr const int RDB14BitLen = 1;
 constexpr const int RDBEncVal = 3;
-constexpr const int RDB32BitLen = 0x08;
+constexpr const int RDB32BitLen = 0x80;
 constexpr const int RDB64BitLen = 0x81;
 constexpr const int RDBEncInt8 = 0;
 constexpr const int RDBEncInt16 = 1;
 constexpr const int RDBEncInt32 = 2;
 constexpr const int RDBEncLzf = 3;
 
-Status RDB::peekOk(size_t n) {
-  if (pos_ + n > input_.size()) {
-    return {Status::NotOK, "unexpected EOF"};
-  }
-  return Status::OK();
-}
-
-Status RDB::VerifyPayloadChecksum() {
-  if (input_.size() < 10) {
+/* Special RDB opcodes (saved/loaded with rdbSaveType/rdbLoadType). */
+constexpr const int RDBOpcodeFunction2 = 245;    /* function library data */
+constexpr const int RDBOpcodeFunction = 246;     /* old function library data 
for 7.0 rc1 and rc2 */
+constexpr const int RDBOpcodeModuleAux = 247;    /* Module auxiliary data. */
+constexpr const int RDBOpcodeIdle = 248;         /* LRU idle time. */
+constexpr const int RDBOpcodeFreq = 249;         /* LFU frequency. */
+constexpr const int RDBOpcodeAux = 250;          /* RDB aux field. */
+constexpr const int RDBOpcodeResizeDB = 251;     /* Hash table resize hint. */
+constexpr const int RDBOpcodeExpireTimeMs = 252; /* Expire time in 
milliseconds. */
+constexpr const int RDBOpcodeExpireTime = 253;   /* Old expire time in 
seconds. */
+constexpr const int RDBOpcodeSelectDB = 254;     /* DB number of the following 
keys. */
+constexpr const int RDBOpcodeEof = 255;          /* End of the RDB file. */
+
+// The current support RDB version
+constexpr const int RDBVersion = 10;
+
+// NOLINTNEXTLINE
+#define GET_OR_RETWITHLOG(...)                                                 
                        \
+  ({                                                                           
                        \
+    auto &&status = (__VA_ARGS__);                                             
                        \
+    if (!status) {                                                             
                        \
+      LOG(WARNING) << "Short read or unsupported type loading DB. 
Unrecoverable error, aborting now."; \
+      LOG(ERROR) << "Unexpected EOF reading RDB file";                         
                        \
+      return std::forward<decltype(status)>(status);                           
                        \
+    }                                                                          
                        \
+    std::forward<decltype(status)>(status);                                    
                        \
+  }).GetValue()

Review Comment:
   Okay



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