Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Extract an MultiGet Options for rocksdb::MultiGet #1582

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/storage/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/types/redis_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/types/redis_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down