zjregee commented on code in PR #2228:
URL: https://github.com/apache/kvrocks/pull/2228#discussion_r1555541936
##########
src/types/redis_json.cc:
##########
@@ -548,6 +548,66 @@ std::vector<rocksdb::Status> Json::MGet(const
std::vector<std::string> &user_key
return statuses;
}
+rocksdb::Status Json::MSet(const std::vector<std::string> &user_keys, const
std::vector<std::string> &paths,
+ const std::vector<std::string> &values) {
+ std::optional<MultiLockGuard> guard;
+ std::vector<std::string> lock_keys;
+ lock_keys.reserve(user_keys.size());
+ for (const auto &user_key : user_keys) {
+ std::string ns_key = AppendNamespacePrefix(user_key);
+ lock_keys.emplace_back(std::move(ns_key));
+ }
+ guard.emplace(storage_->GetLockManager(), lock_keys);
+
+ auto batch = storage_->GetWriteBatchBase();
+ WriteBatchLogData log_data(kRedisJson);
+ batch->PutLogData(log_data.Encode());
+
+ for (size_t i = 0; i < user_keys.size(); i++) {
+ std::string ns_key = AppendNamespacePrefix(user_keys[i]);
Review Comment:
Do you mean like this?
```C++
std::vector<std::string> ns_keys;
ns_keys.reserve(user_keys.size());
for (const auto &user_key : user_keys) {
std::string ns_key = AppendNamespacePrefix(user_key);
ns_keys.emplace_back(std::move(ns_key));
}
MultiLockGuard guard(storage_->GetLockManager(), ns_keys);
...
for (size_t i = 0; i < user_keys.size(); i++) {
...
auto s = read(ns_keys[i], &metadata, &value);
...
}
```
--
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]