This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 7af5bb50 Storage: Extract an MultiGet Options for rocksdb::MultiGet
(#1582)
7af5bb50 is described below
commit 7af5bb508eef566643a1df1ecf1a178468727765
Author: mwish <[email protected]>
AuthorDate: Thu Jul 13 11:33:46 2023 +0800
Storage: Extract an MultiGet Options for rocksdb::MultiGet (#1582)
---
src/storage/storage.cc | 7 +++++++
src/storage/storage.h | 1 +
src/types/redis_hash.cc | 8 ++++----
src/types/redis_string.cc | 2 +-
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index 68bbe119..8b651a0d 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 866eefb4..9b9dcf23 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 278f6207..2946f47e 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<Slice> &fiel
}
LatestSnapShot ss(storage_);
- rocksdb::ReadOptions read_options = storage_->DefaultScanOptions();
+ rocksdb::ReadOptions read_options = storage_->DefaultMultiGetOptions();
read_options.snapshot = ss.GetSnapShot();
std::vector<rocksdb::Slice> keys;
keys.reserve(fields.size());
std::vector<std::string> 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<rocksdb::PinnableSlice> values_vector;
diff --git a/src/types/redis_string.cc b/src/types/redis_string.cc
index 3b1e44c8..d1b5b958 100644
--- a/src/types/redis_string.cc
+++ b/src/types/redis_string.cc
@@ -36,7 +36,7 @@ std::vector<rocksdb::Status> String::getRawValues(const
std::vector<Slice> &keys
std::vector<std::string>
*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());