infdahai commented on code in PR #1453:
URL:
https://github.com/apache/incubator-kvrocks/pull/1453#discussion_r1199772992
##########
src/types/redis_hash.cc:
##########
@@ -174,16 +174,27 @@ rocksdb::Status Hash::MGet(const Slice &user_key, const
std::vector<Slice> &fiel
rocksdb::ReadOptions read_options;
read_options.snapshot = ss.GetSnapShot();
storage_->SetReadOptions(read_options);
+ std::vector<rocksdb::Slice> keys;
- std::string sub_key, value;
+ keys.reserve(fields.size());
+ std::vector<std::string> sub_keys;
+ sub_keys.resize(fields.size());
+ int i = 0;
for (const auto &field : fields) {
- InternalKey(ns_key, field, metadata.version,
storage_->IsSlotIdEncoded()).Encode(&sub_key);
- value.clear();
- s = storage_->Get(read_options, sub_key, &value);
- if (!s.ok() && !s.IsNotFound()) return s;
+ InternalKey(ns_key, field, metadata.version,
storage_->IsSlotIdEncoded()).Encode(&(sub_keys[i]));
+ keys.emplace_back(sub_keys[i++]);
+ }
- values->emplace_back(value);
- statuses->emplace_back(s);
+ std::vector<rocksdb::PinnableSlice> values_vector;
+ values_vector.resize(keys.size());
+ std::vector<rocksdb::Status> statuses_vector;
+ statuses_vector.resize(keys.size());
+ storage_->MultiGet(read_options, storage_->GetDB()->DefaultColumnFamily(),
keys.size(), keys.data(),
+ values_vector.data(), statuses_vector.data());
+ for (size_t i = 0; i < keys.size(); i++) {
+ if (!statuses_vector[i].ok() && statuses_vector[i].IsNotFound()) return
statuses_vector[i];
Review Comment:
This statement corresponds to #1455
--
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]