MCPcopy Create free account
hub / github.com/ElementsProject/elements / PrintContents

Function PrintContents

src/leveldb/db/write_batch_test.cc:15–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace leveldb {
14
15static std::string PrintContents(WriteBatch* b) {
16 InternalKeyComparator cmp(BytewiseComparator());
17 MemTable* mem = new MemTable(cmp);
18 mem->Ref();
19 std::string state;
20 Status s = WriteBatchInternal::InsertInto(b, mem);
21 int count = 0;
22 Iterator* iter = mem->NewIterator();
23 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
24 ParsedInternalKey ikey;
25 ASSERT_TRUE(ParseInternalKey(iter->key(), &ikey));
26 switch (ikey.type) {
27 case kTypeValue:
28 state.append("Put(");
29 state.append(ikey.user_key.ToString());
30 state.append(", ");
31 state.append(iter->value().ToString());
32 state.append(")");
33 count++;
34 break;
35 case kTypeDeletion:
36 state.append("Delete(");
37 state.append(ikey.user_key.ToString());
38 state.append(")");
39 count++;
40 break;
41 }
42 state.append("@");
43 state.append(NumberToString(ikey.sequence));
44 }
45 delete iter;
46 if (!s.ok()) {
47 state.append("ParseError()");
48 } else if (count != WriteBatchInternal::Count(b)) {
49 state.append("CountMismatch()");
50 }
51 mem->Unref();
52 return state;
53}
54
55class WriteBatchTest {};
56

Callers 1

TESTFunction · 0.85

Calls 12

BytewiseComparatorFunction · 0.85
ParseInternalKeyFunction · 0.85
NumberToStringFunction · 0.85
RefMethod · 0.45
NewIteratorMethod · 0.45
SeekToFirstMethod · 0.45
ValidMethod · 0.45
NextMethod · 0.45
keyMethod · 0.45
ToStringMethod · 0.45
valueMethod · 0.45
UnrefMethod · 0.45

Tested by

no test coverage detected