mapleFU commented on code in PR #1901:
URL: https://github.com/apache/kvrocks/pull/1901#discussion_r1405345188


##########
src/types/redis_bitmap.cc:
##########
@@ -539,6 +547,321 @@ rocksdb::Status Bitmap::BitOp(BitOpFlags op_flag, const 
std::string &op_name, co
   return storage_->Write(storage_->DefaultWriteOptions(), 
batch->GetWriteBatch());
 }
 
+// SegmentCacheStore is used to read segments from storage.
+class Bitmap::SegmentCacheStore {
+ public:
+  SegmentCacheStore(engine::Storage *storage, rocksdb::ColumnFamilyHandle 
*metadata_cf_handle,
+                    std::string namespace_key, const Metadata &bitmap_metadata)
+      : storage_(storage),
+        metadata_cf_handle_(metadata_cf_handle),
+        ns_key_(std::move(namespace_key)),
+        metadata_(bitmap_metadata) {}
+
+  // Get a read-only segment by given index
+  rocksdb::Status Get(uint32_t index, const std::string **cache) {
+    std::string *res = nullptr;
+    auto s = get(index, false, &res);

Review Comment:
   ```suggestion
       auto s = get(index, /*set_dirty=*/false, &res);
   ```



##########
src/types/redis_bitmap.cc:
##########
@@ -539,6 +547,321 @@ rocksdb::Status Bitmap::BitOp(BitOpFlags op_flag, const 
std::string &op_name, co
   return storage_->Write(storage_->DefaultWriteOptions(), 
batch->GetWriteBatch());
 }
 
+// SegmentCacheStore is used to read segments from storage.
+class Bitmap::SegmentCacheStore {
+ public:
+  SegmentCacheStore(engine::Storage *storage, rocksdb::ColumnFamilyHandle 
*metadata_cf_handle,
+                    std::string namespace_key, const Metadata &bitmap_metadata)
+      : storage_(storage),
+        metadata_cf_handle_(metadata_cf_handle),
+        ns_key_(std::move(namespace_key)),
+        metadata_(bitmap_metadata) {}
+
+  // Get a read-only segment by given index
+  rocksdb::Status Get(uint32_t index, const std::string **cache) {
+    std::string *res = nullptr;
+    auto s = get(index, false, &res);
+    if (s.ok()) {
+      *cache = res;
+    }
+    return s;
+  }
+
+  // Get a segment by given index, and mark it dirty.
+  rocksdb::Status GetMut(uint32_t index, std::string **cache) { return 
get(index, true, cache); }

Review Comment:
   ```suggestion
     rocksdb::Status GetMut(uint32_t index, std::string **cache) { return 
get(index, /*set_dirty=*/true, cache); }
   ```



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