提交 ade4034a 编写于 作者: I Igor Canadi

MultiGet for DBWithTTL

Summary: This is a feature request from rocksdb's user. I didn't even realize we don't support multigets on TTL DB :)

Test Plan: added a unit test

Reviewers: yhchiang, rven, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D30561
上级 fdb6be4e
......@@ -202,8 +202,18 @@ std::vector<Status> DBWithTTLImpl::MultiGet(
const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family,
const std::vector<Slice>& keys, std::vector<std::string>* values) {
return std::vector<Status>(
keys.size(), Status::NotSupported("MultiGet not supported with TTL"));
auto statuses = db_->MultiGet(options, column_family, keys, values);
for (size_t i = 0; i < keys.size(); ++i) {
if (!statuses[i].ok()) {
continue;
}
statuses[i] = SanityCheckTimestamp((*values)[i]);
if (!statuses[i].ok()) {
continue;
}
statuses[i] = StripTS(&(*values)[i]);
}
return statuses;
}
bool DBWithTTLImpl::KeyMayExist(const ReadOptions& options,
......
......@@ -194,6 +194,25 @@ class TtlTest {
}
}
// checks the whole kvmap_ to return correct values using MultiGet
void SimpleMultiGetTest() {
static ReadOptions ropts;
std::vector<Slice> keys;
std::vector<std::string> values;
for (auto& kv : kvmap_) {
keys.emplace_back(kv.first);
}
auto statuses = db_ttl_->MultiGet(ropts, keys, &values);
size_t i = 0;
for (auto& kv : kvmap_) {
ASSERT_OK(statuses[i]);
ASSERT_EQ(values[i], kv.second);
++i;
}
}
// Sleeps for slp_tim then runs a manual compaction
// Checks span starting from st_pos from kvmap_ in the db and
// Gets should return true if check is true and false otherwise
......@@ -533,6 +552,17 @@ TEST(TtlTest, KeyMayExist) {
CloseTtl();
}
TEST(TtlTest, MultiGetTest) {
MakeKVMap(kSampleSize_);
OpenTtl();
PutValues(0, kSampleSize_, false);
SimpleMultiGetTest();
CloseTtl();
}
TEST(TtlTest, ColumnFamiliesTest) {
DB* db;
Options options;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册