PragmaTwice commented on code in PR #2402:
URL: https://github.com/apache/kvrocks/pull/2402#discussion_r1694968273
##########
src/storage/redis_metadata.cc:
##########
@@ -334,6 +334,25 @@ bool Metadata::IsEmptyableType() const {
bool Metadata::Expired() const { return ExpireAt(util::GetTimeStampMS()); }
+bool HashMetadata::IsFieldExpirationEnabled() const { return field_encoding ==
HashSubkeyEncoding::VALUE_WITH_TTL; }
+
+void HashMetadata::Encode(std::string *dst) const {
+ Metadata::Encode(dst);
+ PutFixed8(dst, uint8_t(field_encoding));
+}
+
+rocksdb::Status HashMetadata::Decode(Slice *input) {
+ if (auto s = Metadata::Decode(input); !s.ok()) {
+ return s;
+ }
+
+ if (input->size() >= 1 && !GetFixed8(input, reinterpret_cast<uint8_t
*>(&field_encoding))) {
+ return rocksdb::Status::InvalidArgument(kErrMetadataTooShort);
+ }
Review Comment:
```suggestion
if (input->size() >= 1) {
if (!GetFixed8(input, reinterpret_cast<uint8_t *>(&field_encoding))) {
return rocksdb::Status::InvalidArgument(kErrMetadataTooShort);
}
if (uint8_t(field_encoding) > 1) {
return rocksdb::Status::InvalidArgument("unexpected subkey encoding
version");
}
}
```
--
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]