MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / compressLogHeader

Function compressLogHeader

runtime/Log.h:513–531  ·  view source on GitHub ↗

* Extract the information from an UncompressedLogEntry and re-encode it * as a CompressedRecordEntry. Here, the provided lastTimestamp is provided * so that the CompressedRecordEntry only needs to store a time difference. * * This packs the metadata as follows: * 1 Byte of CompressedMetadata * 1-4 bytes of formatId * 1-8 bytes of rtdsc() difference

Source from the content-addressed store, hash-verified

511 * Number of bytes written to out
512 */
513 inline size_t
514 compressLogHeader(const UncompressedEntry *re, char** out,
515 uint64_t lastTimestamp) {
516 CompressedEntry *mo = reinterpret_cast<CompressedEntry*>(*out);
517 *out += sizeof(CompressedEntry);
518
519 mo->entryType = EntryType::LOG_MSGS_OR_DIC;
520
521 // Bitmask is needed to prevent -Wconversion warnings
522 mo->additionalFmtIdBytes = 0x03 & static_cast<uint8_t>(
523 BufferUtils::pack(out, re->fmtId) - 1);
524 mo->additionalTimestampBytes = 0x0F & static_cast<uint8_t>(
525 BufferUtils::pack(out, static_cast<int64_t>(
526 re->timestamp - lastTimestamp)));
527
528 return sizeof(CompressedEntry)
529 + mo->additionalFmtIdBytes + 1
530 + (0x7 & mo->additionalTimestampBytes);
531 }
532
533 /**
534 * Read in and decompress the log metadata from a CompressedRecordEntry

Callers 2

encodeLogMsgsMethod · 0.85
TEST_FFunction · 0.85

Calls 1

packFunction · 0.85

Tested by 1

TEST_FFunction · 0.68