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

Function WriteBatchPrinter

src/leveldb/db/dumpfile.cc:97–120  ·  view source on GitHub ↗

Called on every log record (each one of which is a WriteBatch) found in a kLogFile.

Source from the content-addressed store, hash-verified

95// Called on every log record (each one of which is a WriteBatch)
96// found in a kLogFile.
97static void WriteBatchPrinter(uint64_t pos, Slice record, WritableFile* dst) {
98 std::string r = "--- offset ";
99 AppendNumberTo(&r, pos);
100 r += "; ";
101 if (record.size() < 12) {
102 r += "log record length ";
103 AppendNumberTo(&r, record.size());
104 r += " is too small\n";
105 dst->Append(r);
106 return;
107 }
108 WriteBatch batch;
109 WriteBatchInternal::SetContents(&batch, record);
110 r += "sequence ";
111 AppendNumberTo(&r, WriteBatchInternal::Sequence(&batch));
112 r.push_back('\n');
113 dst->Append(r);
114 WriteBatchItemPrinter batch_item_printer;
115 batch_item_printer.dst_ = dst;
116 Status s = batch.Iterate(&batch_item_printer);
117 if (!s.ok()) {
118 dst->Append(" error: " + s.ToString() + "\n");
119 }
120}
121
122Status DumpLog(Env* env, const std::string& fname, WritableFile* dst) {
123 return PrintLogContents(env, fname, WriteBatchPrinter, dst);

Callers

nothing calls this directly

Calls 6

AppendNumberToFunction · 0.85
sizeMethod · 0.45
AppendMethod · 0.45
push_backMethod · 0.45
IterateMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected