Skip to content

Commit 7f3e417

Browse files
committed
Fix memtable construction in tests
1 parent 055e6df commit 7f3e417

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

db/version_edit_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace rocksdb {
1515
static void TestEncodeDecode(const VersionEdit& edit) {
1616
std::string encoded, encoded2;
1717
edit.EncodeTo(&encoded);
18-
VersionEdit parsed();
18+
VersionEdit parsed;
1919
Status s = parsed.DecodeFrom(encoded);
2020
ASSERT_TRUE(s.ok()) << s.ToString();
2121
parsed.EncodeTo(&encoded2);
@@ -27,7 +27,7 @@ class VersionEditTest { };
2727
TEST(VersionEditTest, EncodeDecode) {
2828
static const uint64_t kBig = 1ull << 50;
2929

30-
VersionEdit edit();
30+
VersionEdit edit;
3131
for (int i = 0; i < 4; i++) {
3232
TestEncodeDecode(edit);
3333
edit.AddFile(3, kBig + 300 + i, kBig + 400 + i,

db/write_batch_test.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ namespace rocksdb {
2222
static std::string PrintContents(WriteBatch* b) {
2323
InternalKeyComparator cmp(BytewiseComparator());
2424
auto factory = std::make_shared<SkipListFactory>();
25-
MemTable* mem = new MemTable(cmp, factory.get());
25+
Options options;
26+
options.memtable_factory = factory;
27+
MemTable* mem = new MemTable(cmp, options);
2628
mem->Ref();
2729
std::string state;
28-
Options options;
2930
Status s = WriteBatchInternal::InsertInto(b, mem, &options);
3031
int count = 0;
3132
Iterator* iter = mem->NewIterator();

table/table_test.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,19 @@ class MemTableConstructor: public Constructor {
370370
: Constructor(cmp),
371371
internal_comparator_(cmp),
372372
table_factory_(new SkipListFactory) {
373-
memtable_ = new MemTable(internal_comparator_, table_factory_.get());
373+
Options options;
374+
options.memtable_factory = table_factory_;
375+
memtable_ = new MemTable(internal_comparator_, options);
374376
memtable_->Ref();
375377
}
376378
~MemTableConstructor() {
377379
delete memtable_->Unref();
378380
}
379381
virtual Status FinishImpl(const Options& options, const KVMap& data) {
380382
delete memtable_->Unref();
381-
memtable_ = new MemTable(internal_comparator_, table_factory_.get());
383+
Options memtable_options;
384+
memtable_options.memtable_factory = table_factory_;
385+
memtable_ = new MemTable(internal_comparator_, memtable_options);
382386
memtable_->Ref();
383387
int seq = 1;
384388
for (KVMap::const_iterator it = data.begin();
@@ -1268,10 +1272,11 @@ class MemTableTest { };
12681272
TEST(MemTableTest, Simple) {
12691273
InternalKeyComparator cmp(BytewiseComparator());
12701274
auto table_factory = std::make_shared<SkipListFactory>();
1271-
MemTable* memtable = new MemTable(cmp, table_factory.get());
1275+
Options options;
1276+
options.memtable_factory = table_factory;
1277+
MemTable* memtable = new MemTable(cmp, options);
12721278
memtable->Ref();
12731279
WriteBatch batch;
1274-
Options options;
12751280
WriteBatchInternal::SetSequence(&batch, 100);
12761281
batch.Put(std::string("k1"), std::string("v1"));
12771282
batch.Put(std::string("k2"), std::string("v2"));

0 commit comments

Comments
 (0)