enjoy-binbin commented on code in PR #1712:
URL: https://github.com/apache/kvrocks/pull/1712#discussion_r1314417520


##########
src/storage/redis_db.cc:
##########
@@ -121,6 +121,39 @@ rocksdb::Status Database::Del(const Slice &user_key) {
   return storage_->Delete(storage_->DefaultWriteOptions(), 
metadata_cf_handle_, ns_key);
 }
 
+rocksdb::Status Database::MDel(const std::vector<Slice> &keys, uint64_t 
*deleted_cnt) {
+  *deleted_cnt = 0;
+
+  std::vector<std::string> lock_keys;
+  lock_keys.reserve(keys.size());
+  for (const auto &key : keys) {
+    std::string ns_key = AppendNamespacePrefix(key);
+    lock_keys.emplace_back(std::move(ns_key));
+  }
+  MultiLockGuard guard(storage_->GetLockManager(), lock_keys);
+
+  auto batch = storage_->GetWriteBatchBase();
+  WriteBatchLogData log_data(kRedisNone);
+  batch->PutLogData(log_data.Encode());
+
+  for (const auto &ns_key : lock_keys) {
+    std::string value;
+    rocksdb::Status s = storage_->Get(rocksdb::ReadOptions(), 
metadata_cf_handle_, ns_key, &value);
+    if (!s.ok()) continue;

Review Comment:
   ohh, sorry, i missed this comment (thought it is ok to continue). yean, it 
is ok to return the error.
   
   we do had some commands that will do the continue, like `EXISTS`. i will 
change it too.
   ```
   rocksdb::Status Database::Exists(const std::vector<Slice> &keys, int *ret) {
     *ret = 0;
     LatestSnapShot ss(storage_);
     rocksdb::ReadOptions read_options;
     read_options.snapshot = ss.GetSnapShot();
   
     rocksdb::Status s;
     std::string value;
     for (const auto &key : keys) {
       std::string ns_key = AppendNamespacePrefix(key);
       s = storage_->Get(read_options, metadata_cf_handle_, ns_key, &value);
       if (s.ok()) {
         Metadata metadata(kRedisNone, false);
         metadata.Decode(value);
         if (!metadata.Expired()) *ret += 1;
       }
     }
     return rocksdb::Status::OK();
   }
   ```



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