|
@ -20,11 +20,10 @@ Status OpenDB(std::string dbName, DB **db) { |
|
|
void InsertData(DB *db, uint64_t ttl/* second */) { |
|
|
void InsertData(DB *db, uint64_t ttl/* second */) { |
|
|
WriteOptions writeOptions; |
|
|
WriteOptions writeOptions; |
|
|
int key_num = data_size / value_size; |
|
|
int key_num = data_size / value_size; |
|
|
srand(static_cast<unsigned int>(time(0))); |
|
|
|
|
|
//srand(0);
|
|
|
|
|
|
|
|
|
//srand(static_cast<unsigned int>(time(0)));
|
|
|
|
|
|
srand(0); |
|
|
for (int i = 0; i < key_num; i++) { |
|
|
for (int i = 0; i < key_num; i++) { |
|
|
//int key_ = rand() % key_num+1;
|
|
|
|
|
|
int key_ = i + 1; |
|
|
|
|
|
|
|
|
int key_ = rand() % key_num+1; |
|
|
std::string key = std::to_string(key_); |
|
|
std::string key = std::to_string(key_); |
|
|
std::string value(value_size, 'a'); |
|
|
std::string value(value_size, 'a'); |
|
|
db->Put(writeOptions, key, value, ttl); |
|
|
db->Put(writeOptions, key, value, ttl); |
|
@ -36,8 +35,8 @@ void GetData(DB *db, int size = (1 << 30)) { |
|
|
int key_num = data_size / value_size; |
|
|
int key_num = data_size / value_size; |
|
|
|
|
|
|
|
|
// 点查
|
|
|
// 点查
|
|
|
srand(static_cast<unsigned int>(time(0))); |
|
|
|
|
|
//srand(0);
|
|
|
|
|
|
|
|
|
//srand(static_cast<unsigned int>(time(0)));
|
|
|
|
|
|
srand(0); |
|
|
for (int i = 0; i < 100; i++) { |
|
|
for (int i = 0; i < 100; i++) { |
|
|
int key_ = rand() % key_num+1; |
|
|
int key_ = rand() % key_num+1; |
|
|
std::string key = std::to_string(key_); |
|
|
std::string key = std::to_string(key_); |
|
@ -60,7 +59,8 @@ TEST(TestTTL, ReadTTL) { |
|
|
ReadOptions readOptions; |
|
|
ReadOptions readOptions; |
|
|
Status status; |
|
|
Status status; |
|
|
int key_num = data_size / value_size; |
|
|
int key_num = data_size / value_size; |
|
|
srand(static_cast<unsigned int>(time(0))); |
|
|
|
|
|
|
|
|
//srand(static_cast<unsigned int>(time(0)));
|
|
|
|
|
|
srand(0); |
|
|
for (int i = 0; i < 100; i++) { |
|
|
for (int i = 0; i < 100; i++) { |
|
|
int key_ = rand() % key_num+1; |
|
|
int key_ = rand() % key_num+1; |
|
|
std::string key = std::to_string(key_); |
|
|
std::string key = std::to_string(key_); |
|
|