wal_utils.go
wal_utils.go - Overview
This file provides utility functions and constants for handling Write-Ahead Log (WAL) entries, including marshaling, unmarshaling, and size calculation.
Detailed Documentation
Constants
versionTagSize
: Size of the tag for the "version" field (1 byte).versionLengthPrefixSize
: Size of the length prefix for the "version" field (1 byte).versionSize
: Fixed size of the "version" string (6 bytes, e.g., "v0.0.1").logSequenceNumberSize
: Size of the log sequence number (8 bytes).dataTagSize
: Size of the tag for the "data" field (1 byte).dataLengthPrefixSize
: Size of the length prefix for the "data" field (1 byte).CRCSize
: Size of the CRC checksum (4 bytes).timestampSize
: Size of the timestamp (8 bytes).
MustMarshal
- Purpose: Marshals a
WALEntry
into a byte slice using theproto.Marshal
function. Panics if marshaling fails. - Parameters:
entry
: A pointer to theWALEntry
to be marshaled.
- Returns: A byte slice containing the marshaled
WALEntry
.
MustUnmarshal
- Purpose: Unmarshals a byte slice into a
WALEntry
using theproto.Unmarshal
function. Panics if unmarshaling fails. - Parameters:
data
: A byte slice containing the data to be unmarshaled.entry
: A pointer to theWALEntry
to which the data will be unmarshaled.
- Returns: None.
getEntrySize
- Purpose: Calculates the total size of a WAL entry based on the size of its data field.
- Parameters:
data
: A byte slice representing the data field of the WAL entry.
- Returns: An integer representing the total size of the WAL entry in bytes.