diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 68bbe119edf..8b651a0d351 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -94,6 +94,13 @@ rocksdb::ReadOptions Storage::DefaultScanOptions() const { return read_options; } +rocksdb::ReadOptions Storage::DefaultMultiGetOptions() const { + rocksdb::ReadOptions read_options; + read_options.async_io = config_->rocks_db.read_options.async_io; + + return read_options; +} + rocksdb::BlockBasedTableOptions Storage::InitTableOptions() { rocksdb::BlockBasedTableOptions table_options; table_options.format_version = 5; diff --git a/src/storage/storage.h b/src/storage/storage.h index 866eefb4d48..9b9dcf238f7 100644 --- a/src/storage/storage.h +++ b/src/storage/storage.h @@ -99,6 +99,7 @@ class Storage { rocksdb::Status Write(const rocksdb::WriteOptions &options, rocksdb::WriteBatch *updates); const rocksdb::WriteOptions &DefaultWriteOptions() { return write_opts_; } rocksdb::ReadOptions DefaultScanOptions() const; + rocksdb::ReadOptions DefaultMultiGetOptions() const; rocksdb::Status Delete(const rocksdb::WriteOptions &options, rocksdb::ColumnFamilyHandle *cf_handle, const rocksdb::Slice &key); rocksdb::Status DeleteRange(const std::string &first_key, const std::string &last_key); diff --git a/src/types/redis_hash.cc b/src/types/redis_hash.cc index 278f62077d0..2946f47edcc 100644 --- a/src/types/redis_hash.cc +++ b/src/types/redis_hash.cc @@ -171,17 +171,17 @@ rocksdb::Status Hash::MGet(const Slice &user_key, const std::vector &fiel } LatestSnapShot ss(storage_); - rocksdb::ReadOptions read_options = storage_->DefaultScanOptions(); + rocksdb::ReadOptions read_options = storage_->DefaultMultiGetOptions(); read_options.snapshot = ss.GetSnapShot(); std::vector keys; keys.reserve(fields.size()); std::vector sub_keys; sub_keys.resize(fields.size()); - int i = 0; - for (const auto &field : fields) { + for (size_t i = 0; i < fields.size(); i++) { + auto &field = fields[i]; InternalKey(ns_key, field, metadata.version, storage_->IsSlotIdEncoded()).Encode(&(sub_keys[i])); - keys.emplace_back(sub_keys[i++]); + keys.emplace_back(sub_keys[i]); } std::vector values_vector; diff --git a/src/types/redis_string.cc b/src/types/redis_string.cc index 3b1e44c84e5..d1b5b958f1c 100644 --- a/src/types/redis_string.cc +++ b/src/types/redis_string.cc @@ -36,7 +36,7 @@ std::vector String::getRawValues(const std::vector &keys std::vector *raw_values) { raw_values->clear(); - rocksdb::ReadOptions read_options; + rocksdb::ReadOptions read_options = storage_->DefaultMultiGetOptions(); LatestSnapShot ss(storage_); read_options.snapshot = ss.GetSnapShot(); raw_values->resize(keys.size());