|
@ -40,41 +40,41 @@ void GetData(DB *db, int size = (1 << 30)) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TEST(TestTTL, ReadTTL) {
|
|
|
|
|
|
// DB *db;
|
|
|
|
|
|
// if(OpenDB("testdb", &db).ok() == false) {
|
|
|
|
|
|
// std::cerr << "open db failed" << std::endl;
|
|
|
|
|
|
// abort();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// uint64_t ttl = 20;
|
|
|
|
|
|
|
|
|
|
|
|
// InsertData(db, ttl);
|
|
|
|
|
|
|
|
|
|
|
|
// ReadOptions readOptions;
|
|
|
|
|
|
// Status status;
|
|
|
|
|
|
// int key_num = data_size / value_size;
|
|
|
|
|
|
// srand(0);
|
|
|
|
|
|
// for (int i = 0; i < 100; i++) {
|
|
|
|
|
|
// int key_ = rand() % key_num+1;
|
|
|
|
|
|
// std::string key = std::to_string(key_);
|
|
|
|
|
|
// std::string value;
|
|
|
|
|
|
// status = db->Get(readOptions, key, &value);
|
|
|
|
|
|
// ASSERT_TRUE(status.ok());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// Env::Default()->SleepForMicroseconds(ttl * 1000000);
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < 100; i++) {
|
|
|
|
|
|
// int key_ = rand() % key_num+1;
|
|
|
|
|
|
// std::string key = std::to_string(key_);
|
|
|
|
|
|
// std::string value;
|
|
|
|
|
|
// status = db->Get(readOptions, key, &value);
|
|
|
|
|
|
// ASSERT_FALSE(status.ok());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// delete db;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
TEST(TestTTL, ReadTTL) { |
|
|
|
|
|
DB *db; |
|
|
|
|
|
if(OpenDB("testdb", &db).ok() == false) { |
|
|
|
|
|
std::cerr << "open db failed" << std::endl; |
|
|
|
|
|
abort(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint64_t ttl = 20; |
|
|
|
|
|
|
|
|
|
|
|
InsertData(db, ttl); |
|
|
|
|
|
|
|
|
|
|
|
ReadOptions readOptions; |
|
|
|
|
|
Status status; |
|
|
|
|
|
int key_num = data_size / value_size; |
|
|
|
|
|
srand(0); |
|
|
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
|
|
int key_ = rand() % key_num+1; |
|
|
|
|
|
std::string key = std::to_string(key_); |
|
|
|
|
|
std::string value; |
|
|
|
|
|
status = db->Get(readOptions, key, &value); |
|
|
|
|
|
ASSERT_TRUE(status.ok()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Env::Default()->SleepForMicroseconds(ttl * 1000000); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) { |
|
|
|
|
|
int key_ = rand() % key_num+1; |
|
|
|
|
|
std::string key = std::to_string(key_); |
|
|
|
|
|
std::string value; |
|
|
|
|
|
status = db->Get(readOptions, key, &value); |
|
|
|
|
|
ASSERT_FALSE(status.ok()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete db; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
TEST(TestTTL, CompactionTTL) { |
|
|
TEST(TestTTL, CompactionTTL) { |
|
|
DB *db; |
|
|
DB *db; |
|
|