Documentation ¶
Index ¶
Constants ¶
const ( DataFileSuffix = ".data" HintFileSuffix = "hintIndex" MergeFinaFileSuffix = "mergeFina" )
Variables ¶
var (
ErrInvalidCRC = errors.New("InvalidCrcError : invalid crc value, log record maybe corrupted")
)
Functions ¶
func EncodeLogRecord ¶
EncodeLogRecord encodes a LogRecord and returns the byte array and length. +-------------+------------+------------+--------------+-------+---------+---------+---------+---------+ | crc checksum | record type | key size | value size | key | value | +-------------+------------+------------+--------------+-------+---------+ | 4 bytes | 1 byte | variable (max 5) | variable (max 5) | variable | variable | +-------------+------------+------------+--------------+-------+---------+---------+---------+---------+
func EncodeLogRecordPst ¶
func EncodeLogRecordPst(pst *LogRecordPst) []byte
EncodeLogRecordPst encodes the position information of a log record.
func GetDataFileName ¶
GetDataFileName returns the file name for a data file.
Types ¶
type DataFile ¶
type DataFile struct { FileID uint32 // File ID WriteOff int64 // Position where the file is currently being written IoManager fileio.IOManager // IO read/write operations }
DataFile represents a data file.
func OpenDataFile ¶
OpenDataFile opens a new data file.
func OpenHintFile ¶
OpenHintFile opens the hint index file.
func OpenMergeFinaFile ¶
OpenMergeFinaFile opens the file that indicates merge completion.
func (*DataFile) ReadLogRecord ¶
ReadLogRecord reads a log record from the data file based on the offset.
func (*DataFile) WriteHintRecord ¶
func (df *DataFile) WriteHintRecord(key []byte, pst *LogRecordPst) error
WriteHintRecord writes index information to the hint file.
type LogRecord ¶
type LogRecord struct { Key []byte // The key of the record Value []byte // The value of the record Type LogRecrdType // The type of the record }
LogRecord represents a record written to the data file.
type LogRecordHeader ¶
type LogRecordHeader struct {
// contains filtered or unexported fields
}
LogRecordHeader represents the header information of a LogRecord.
type LogRecordPst ¶
type LogRecordPst struct { Fid uint32 // File ID: Indicates which file the data is stored in Offset int64 // Offset: Indicates the position in the data file where the data is stored }
LogRecordPst represents the in-memory index of data, mainly describing the location of data on disk.
func DecodeLogRecordPst ¶
func DecodeLogRecordPst(buf []byte) *LogRecordPst
DecodeLogRecordPst decodes the position information from a byte buffer.
type LogRecrdType ¶
type LogRecrdType = byte
const ( LogRecordNormal LogRecrdType = iota LogRecordDeleted LogRecordTransFinished )
type TransactionRecord ¶
type TransactionRecord struct { Record *LogRecord // The log record associated with the transaction Pos *LogRecordPst // The position of the log record in the data file }
TransactionRecord temporarily holds transaction-related data.