From 344e832f55645011188bb17ea33b90431af1a823 Mon Sep 17 00:00:00 2001 From: Abhishek Kona Date: Mon, 22 Apr 2013 10:41:59 -0700 Subject: [PATCH] [RocksDB] Fix ReadMissing in db_bench Summary: D8943 Broke read_missing. Fix it by adding a "." at the end of the generated key Test Plan: generate, print and check the key has a "." Reviewers: dhruba, haobo Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D10455 --- db/db_bench.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index b73fce310..2ce0356c6 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -762,13 +762,13 @@ void ConstructStrFormatForKey(char* str, int keySize) { str[0] = '%'; str[1] = '0'; - sprintf(str+2, "%dd", keySize); + sprintf(str+2, "%dd%s", keySize, "%s"); } -unique_ptr GenerateKeyFromInt(int v) +unique_ptr GenerateKeyFromInt(int v, const char* suffix = "") { unique_ptr keyInStr(new char[MAX_KEY_SIZE]); - snprintf(keyInStr.get(), MAX_KEY_SIZE, keyFormat_, v); + snprintf(keyInStr.get(), MAX_KEY_SIZE, keyFormat_, v, suffix); return keyInStr; } void Run() { @@ -1214,7 +1214,6 @@ unique_ptr GenerateKeyFromInt(int v) while (!duration.Done(1)) { const int k = thread->rand.Next() % FLAGS_num; unique_ptr key = GenerateKeyFromInt(k); - if (FLAGS_use_snapshot) { options.snapshot = db_->GetSnapshot(); } @@ -1262,7 +1261,7 @@ unique_ptr GenerateKeyFromInt(int v) std::string value; while (!duration.Done(1)) { const int k = thread->rand.Next() % FLAGS_num; - unique_ptr key = GenerateKeyFromInt(k); + unique_ptr key = GenerateKeyFromInt(k, "."); db_->Get(options, key.get(), &value); thread->stats.FinishedSingleOp(db_); }