jihuayu commented on code in PR #2174:
URL: https://github.com/apache/kvrocks/pull/2174#discussion_r1527477992


##########
src/storage/redis_db.h:
##########
@@ -33,12 +33,19 @@ class Database {
  public:
   static constexpr uint64_t RANDOM_KEY_SCAN_LIMIT = 60;
 
+  struct GetOptions {
+    // If snapshot is not nullptr, read from the specified snapshot,
+    // otherwise read from the "latest" snapshot.
+    const rocksdb::Snapshot *snapshot = nullptr;
+  };
+
   explicit Database(engine::Storage *storage, std::string ns = "");
   [[nodiscard]] rocksdb::Status ParseMetadata(RedisTypes types, Slice *bytes, 
Metadata *metadata);
-  [[nodiscard]] rocksdb::Status GetMetadata(RedisTypes types, const Slice 
&ns_key, Metadata *metadata);
-  [[nodiscard]] rocksdb::Status GetMetadata(RedisTypes types, const Slice 
&ns_key, std::string *raw_value,
-                                            Metadata *metadata, Slice *rest);
-  [[nodiscard]] rocksdb::Status GetRawMetadata(const Slice &ns_key, 
std::string *bytes);
+  [[nodiscard]] rocksdb::Status GetMetadata(GetOptions options, RedisTypes 
types, const Slice &ns_key,

Review Comment:
   Can we add a simple comment here?
   GetMetadata is an API that most new developers will use. The longgggg list 
of parameters can be overwhelming for them. Adding a simple comment can help 
boost their confidence in writing code.
   
   In my personal experience, new developers may not immediately grasp the 
purpose of snapshots.



##########
src/storage/redis_db.h:
##########
@@ -33,12 +33,19 @@ class Database {
  public:
   static constexpr uint64_t RANDOM_KEY_SCAN_LIMIT = 60;
 
+  struct GetOptions {
+    // If snapshot is not nullptr, read from the specified snapshot,
+    // otherwise read from the "latest" snapshot.
+    const rocksdb::Snapshot *snapshot = nullptr;
+  };
+
   explicit Database(engine::Storage *storage, std::string ns = "");
   [[nodiscard]] rocksdb::Status ParseMetadata(RedisTypes types, Slice *bytes, 
Metadata *metadata);
-  [[nodiscard]] rocksdb::Status GetMetadata(RedisTypes types, const Slice 
&ns_key, Metadata *metadata);
-  [[nodiscard]] rocksdb::Status GetMetadata(RedisTypes types, const Slice 
&ns_key, std::string *raw_value,
-                                            Metadata *metadata, Slice *rest);
-  [[nodiscard]] rocksdb::Status GetRawMetadata(const Slice &ns_key, 
std::string *bytes);
+  [[nodiscard]] rocksdb::Status GetMetadata(GetOptions options, RedisTypes 
types, const Slice &ns_key,

Review Comment:
   Can we add a simple comment here?
   GetMetadata is an API that most new developers will use. The longgggg list 
of parameters can be overwhelming for them. Adding a simple comment can help 
boost their confidence in writing code.
   
   In my personal experience, new developers may not immediately get the 
purpose of snapshots.



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