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


##########
src/types/redis_bloom_chain.cc:
##########
@@ -51,11 +51,13 @@ rocksdb::Status BloomChain::getBFDataList(const 
std::vector<std::string> &bf_key
   read_options.snapshot = ss.GetSnapShot();
 
   bf_data_list->reserve(bf_key_list.size());
-  for (const auto &bf_key : bf_key_list) {
-    std::string bf_data;
-    rocksdb::Status s = storage_->Get(read_options, bf_key, &bf_data);
+  rocksdb::PinnableSlice pin_value;
+  for (int i = 0; i < bf_key_list.size(); ++i) {
+    auto &bf_key = bf_key_list[i];
+    rocksdb::Status s = storage_->Get(read_options, 
storage_->GetDB()->DefaultColumnFamily(), bf_key, &pin_value);
     if (!s.ok()) return s;
-    bf_data_list->push_back(std::move(bf_data));
+    bf_data_list->emplace_back(pin_value.ToString());
+    pin_value.Reset();

Review Comment:
   I think `getBFDataList` can also get a slice to avoid copying here 🤔



##########
src/types/redis_bloom_chain.cc:
##########
@@ -51,11 +51,13 @@ rocksdb::Status BloomChain::getBFDataList(const 
std::vector<std::string> &bf_key
   read_options.snapshot = ss.GetSnapShot();
 
   bf_data_list->reserve(bf_key_list.size());
-  for (const auto &bf_key : bf_key_list) {
-    std::string bf_data;
-    rocksdb::Status s = storage_->Get(read_options, bf_key, &bf_data);
+  rocksdb::PinnableSlice pin_value;
+  for (int i = 0; i < bf_key_list.size(); ++i) {
+    auto &bf_key = bf_key_list[i];
+    rocksdb::Status s = storage_->Get(read_options, 
storage_->GetDB()->DefaultColumnFamily(), bf_key, &pin_value);
     if (!s.ok()) return s;
-    bf_data_list->push_back(std::move(bf_data));
+    bf_data_list->emplace_back(pin_value.ToString());
+    pin_value.Reset();

Review Comment:
   I think `getBFDataList` can also get a slice to avoid copying here 🤔



##########
src/storage/storage.cc:
##########
@@ -528,6 +528,14 @@ rocksdb::Status Storage::Get(const rocksdb::ReadOptions 
&options, rocksdb::Colum
   return db_->Get(options, column_family, key, value);
 }
 
+rocksdb::Status Storage::Get(const rocksdb::ReadOptions &options, 
rocksdb::ColumnFamilyHandle *column_family, 

Review Comment:
   we can also support a 
   
   ```
   rocksdb::Status Storage::Get(const rocksdb::ReadOptions &options, const 
rocksdb::Slice &key, rocksdb::PinnableSlice *value) {
     return Get(options, db_->DefaultColumnFamily(), key, value);
   }
   ```
   
   Wrapper, and make caller more convient



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