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
main
Igor Canadi 10 years ago
parent fdb6be4e24
commit ade4034a9d
  1. 14
      utilities/ttl/db_ttl_impl.cc
  2. 30
      utilities/ttl/ttl_test.cc

@ -202,8 +202,18 @@ std::vector<Status> DBWithTTLImpl::MultiGet(
const ReadOptions& options, const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family, const std::vector<ColumnFamilyHandle*>& column_family,
const std::vector<Slice>& keys, std::vector<std::string>* values) { const std::vector<Slice>& keys, std::vector<std::string>* values) {
return std::vector<Status>( auto statuses = db_->MultiGet(options, column_family, keys, values);
keys.size(), Status::NotSupported("MultiGet not supported with TTL")); 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, 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 // Sleeps for slp_tim then runs a manual compaction
// Checks span starting from st_pos from kvmap_ in the db and // Checks span starting from st_pos from kvmap_ in the db and
// Gets should return true if check is true and false otherwise // Gets should return true if check is true and false otherwise
@ -533,6 +552,17 @@ TEST(TtlTest, KeyMayExist) {
CloseTtl(); CloseTtl();
} }
TEST(TtlTest, MultiGetTest) {
MakeKVMap(kSampleSize_);
OpenTtl();
PutValues(0, kSampleSize_, false);
SimpleMultiGetTest();
CloseTtl();
}
TEST(TtlTest, ColumnFamiliesTest) { TEST(TtlTest, ColumnFamiliesTest) {
DB* db; DB* db;
Options options; Options options;

Loading…
Cancel
Save