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

Method EmitPhysicalRecord

src/leveldb/db/log_writer.cc:82–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr,
83 size_t length) {
84 assert(length <= 0xffff); // Must fit in two bytes
85 assert(block_offset_ + kHeaderSize + length <= kBlockSize);
86
87 // Format the header
88 char buf[kHeaderSize];
89 buf[4] = static_cast<char>(length & 0xff);
90 buf[5] = static_cast<char>(length >> 8);
91 buf[6] = static_cast<char>(t);
92
93 // Compute the crc of the record type and the payload.
94 uint32_t crc = crc32c::Extend(type_crc_[t], ptr, length);
95 crc = crc32c::Mask(crc); // Adjust for storage
96 EncodeFixed32(buf, crc);
97
98 // Write the header and the payload
99 Status s = dest_->Append(Slice(buf, kHeaderSize));
100 if (s.ok()) {
101 s = dest_->Append(Slice(ptr, length));
102 if (s.ok()) {
103 s = dest_->Flush();
104 }
105 }
106 block_offset_ += kHeaderSize + length;
107 return s;
108}
109
110} // namespace log
111} // namespace leveldb

Callers

nothing calls this directly

Calls 6

EncodeFixed32Function · 0.85
ExtendFunction · 0.50
MaskFunction · 0.50
SliceClass · 0.50
AppendMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected