Don't do memtable lookup in db_impl_readonly if memtables are empty while opening db.

Summary: In DBImpl::Recover method, while loading memtables, also check if memtables are empty. Use this in DBImplReadonly to determine whether to lookup memtable or not.

Test Plan:
db_test
make check all

Reviewers: sdong, yhchiang, ljin, igor

Reviewed By: ljin

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D22281
main
Radheshyam Balasundaram 10 years ago
parent 9dcb75b6d9
commit b6fd7811eb
  1. 1
      Makefile
  2. 1
      db/db_impl_readonly.cc
  3. 10
      db/db_test.cc
  4. 5
      db/memtable.cc

@ -117,7 +117,6 @@ TESTS = \
thread_local_test \
geodb_test \
rate_limiter_test \
cuckoo_table_builder_test \
options_test \
cuckoo_table_builder_test \
cuckoo_table_reader_test \

@ -16,7 +16,6 @@
#include <stdint.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include "db/db_iter.h"
#include "db/dbformat.h"
#include "db/filename.h"

@ -1195,6 +1195,16 @@ TEST(DBTest, ReadOnlyDB) {
}
ASSERT_EQ(count, 2);
delete iter;
Close();
// Reopen and flush memtable.
Reopen();
Flush();
Close();
// Now check keys in read only mode.
ASSERT_OK(ReadOnlyReopen(&options));
ASSERT_EQ("v3", Get("foo"));
ASSERT_EQ("v2", Get("bar"));
}
// Make sure that when options.block_cache is set, after a new table is

@ -417,6 +417,11 @@ static bool SaveValue(void* arg, const char* entry) {
bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
MergeContext& merge_context, const Options& options) {
// The sequence number is updated synchronously in version_set.h
if (first_seqno_ == 0) {
// Avoiding recording stats for speed.
return false;
}
PERF_TIMER_AUTO(get_from_memtable_time);
Slice user_key = key.user_key();

Loading…
Cancel
Save