MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / decodeLogRecordHeader

Function decodeLogRecordHeader

engine/data/log_record.go:103–124  ·  view source on GitHub ↗

decodeLogRecordHeader decodes the header information from a byte buffer.

(buf []byte)

Source from the content-addressed store, hash-verified

101
102// decodeLogRecordHeader decodes the header information from a byte buffer.
103func decodeLogRecordHeader(buf []byte) (*LogRecordHeader, int64) {
104 if len(buf) <= 4 {
105 return nil, 0
106 }
107
108 header := &LogRecordHeader{
109 crc: binary.LittleEndian.Uint32(buf[:4]), // Decode CRC checksum
110 recordType: buf[4], // Decode record type
111 }
112
113 var headerIndex = 5
114 // Extract key/value sizes
115 keySize, lens := binary.Varint(buf[headerIndex:]) // Decode key size
116 header.keySize = uint32(keySize)
117 headerIndex += lens
118
119 valueSize, lens := binary.Varint(buf[headerIndex:]) // Decode value size
120 header.valueSize = uint32(valueSize)
121 headerIndex += lens
122
123 return header, int64(headerIndex)
124}
125
126// getLogRecordCRC calculates the CRC checksum for a LogRecord.
127func getLogRecordCRC(logRecord *LogRecord, header []byte) uint32 {

Callers 2

ReadLogRecordMethod · 0.85
TestDecodeLogRecordFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDecodeLogRecordFunction · 0.68