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 对 LogRecord 进行编码,返回字节数组和长度 +-------------+------------+------------+--------------+-------+---------+ | crc 校验值 | type 类型 | key size | value size | key | value | +-------------+------------+------------+--------------+-------+---------+ | 4 字节 | 1 字节 | 变长(最大5) | 变长(最大5) | 变长 | 变长 | +-------------+------------+------------+--------------+-------+---------+
func EncodeLogRecordPst ¶
func EncodeLogRecordPst(pst *LogRecordPst) []byte
EncodeLogRecordPst 对位置信息进行编码
func GetDataFileName ¶
Types ¶
type DataFile ¶
type DataFile struct {
FileID uint32 //文件id
WriteOff int64 //文件写到了哪个位置
IoManager fio.IOManager //io 读写操作
}
DataFile 数据文件
func OpenDataFile ¶
OpenDataFile 打开新的数据文件
func OpenMergeFinaFile ¶
OpenMergeFinaFile 打开标识 merge 完成的文件
func (*DataFile) ReadLogRecord ¶
ReadLogRecord 根据 offset 从数据文件中读取 logRecord
func (*DataFile) WriteHintRecord ¶
func (df *DataFile) WriteHintRecord(key []byte, pst *LogRecordPst) error
WriteHintRecord 写入索引信息到 hint 文件中
type LogRecord ¶
type LogRecord struct {
Key []byte
Value []byte
Type LogRecrdType
}
LogRecord 写入到数据文件的记录
type LogRecordHeader ¶
type LogRecordHeader struct {
// contains filtered or unexported fields
}
LogRecordHeader LogRecord 的头部信息
type LogRecordPst ¶
type LogRecordPst struct {
Fid uint32 // 文件id,表示将数据存储到了哪个文件当中
Offset int64 // 偏移,表示将数据存储到了数据文件的哪个位置
}
LogRecordPst 数据内存索引, 主要是描述数据在磁盘上的位置
func DecodeLogRecordPst ¶
func DecodeLogRecordPst(buf []byte) *LogRecordPst
DecodeLogRecordPst 对位置信息进行解码
type LogRecrdType ¶
type LogRecrdType = byte
const ( LogRecordNormal LogRecrdType = iota LogRecordDeleted LogRecordTransFinished )
type TransactionRecord ¶
type TransactionRecord struct {
Record *LogRecord
Pos *LogRecordPst
}
TransactionRecord 暂存事务相关的数据