From 7f3e417f59e9f398abca74ceef370b9861cb7523 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 14 Jan 2014 15:32:37 -0800 Subject: [PATCH] Fix memtable construction in tests --- db/version_edit_test.cc | 4 ++-- db/write_batch_test.cc | 5 +++-- table/table_test.cc | 13 +++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/db/version_edit_test.cc b/db/version_edit_test.cc index 745ea90d0..63aa32e8f 100644 --- a/db/version_edit_test.cc +++ b/db/version_edit_test.cc @@ -15,7 +15,7 @@ namespace rocksdb { static void TestEncodeDecode(const VersionEdit& edit) { std::string encoded, encoded2; edit.EncodeTo(&encoded); - VersionEdit parsed(); + VersionEdit parsed; Status s = parsed.DecodeFrom(encoded); ASSERT_TRUE(s.ok()) << s.ToString(); parsed.EncodeTo(&encoded2); @@ -27,7 +27,7 @@ class VersionEditTest { }; TEST(VersionEditTest, EncodeDecode) { static const uint64_t kBig = 1ull << 50; - VersionEdit edit(); + VersionEdit edit; for (int i = 0; i < 4; i++) { TestEncodeDecode(edit); edit.AddFile(3, kBig + 300 + i, kBig + 400 + i, diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc index ff9aa63ee..931d8f3f5 100644 --- a/db/write_batch_test.cc +++ b/db/write_batch_test.cc @@ -22,10 +22,11 @@ namespace rocksdb { static std::string PrintContents(WriteBatch* b) { InternalKeyComparator cmp(BytewiseComparator()); auto factory = std::make_shared(); - MemTable* mem = new MemTable(cmp, factory.get()); + Options options; + options.memtable_factory = factory; + MemTable* mem = new MemTable(cmp, options); mem->Ref(); std::string state; - Options options; Status s = WriteBatchInternal::InsertInto(b, mem, &options); int count = 0; Iterator* iter = mem->NewIterator(); diff --git a/table/table_test.cc b/table/table_test.cc index 1f79fcdf9..d404e0b2a 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -370,7 +370,9 @@ class MemTableConstructor: public Constructor { : Constructor(cmp), internal_comparator_(cmp), table_factory_(new SkipListFactory) { - memtable_ = new MemTable(internal_comparator_, table_factory_.get()); + Options options; + options.memtable_factory = table_factory_; + memtable_ = new MemTable(internal_comparator_, options); memtable_->Ref(); } ~MemTableConstructor() { @@ -378,7 +380,9 @@ class MemTableConstructor: public Constructor { } virtual Status FinishImpl(const Options& options, const KVMap& data) { delete memtable_->Unref(); - memtable_ = new MemTable(internal_comparator_, table_factory_.get()); + Options memtable_options; + memtable_options.memtable_factory = table_factory_; + memtable_ = new MemTable(internal_comparator_, memtable_options); memtable_->Ref(); int seq = 1; for (KVMap::const_iterator it = data.begin(); @@ -1268,10 +1272,11 @@ class MemTableTest { }; TEST(MemTableTest, Simple) { InternalKeyComparator cmp(BytewiseComparator()); auto table_factory = std::make_shared(); - MemTable* memtable = new MemTable(cmp, table_factory.get()); + Options options; + options.memtable_factory = table_factory; + MemTable* memtable = new MemTable(cmp, options); memtable->Ref(); WriteBatch batch; - Options options; WriteBatchInternal::SetSequence(&batch, 100); batch.Put(std::string("k1"), std::string("v1")); batch.Put(std::string("k2"), std::string("v2"));