Documentation
¶
Index ¶
- Constants
- Variables
- func EncodeLogRecord(logRecord *LogRecord) ([]byte, int64)
- func EncodeLogRecordPos(pos *Position) []byte
- func GetDataFileName(dirPath string, fileId uint32) string
- type DataFile
- func (df *DataFile) Close() error
- func (df *DataFile) ReadLogRecord(offset int64) (*LogRecord, int64, error)
- func (df *DataFile) SetIOManager(dirPath string, ioType fio.FileIOType) error
- func (df *DataFile) Sync() error
- func (df *DataFile) Write(buf []byte) error
- func (df *DataFile) WriteHintRecord(key []byte, pos *Position) error
- type LogRecord
- type LogRecordType
- type Position
- type TransactionRecord
Constants ¶
View Source
const ( DataFileNameSuffix = ".data" HintFileName = "hint-index" MergeFinishedFileName = "merge-finished" SeqNoFileName = "seq-no" )
Variables ¶
Functions ¶
func EncodeLogRecord ¶
EncodeLogRecord 对 LogRecord 进行编码,返回字节数组及长度
+-------------+-------------+-------------+--------------+-------------+--------------+
| crc 校验值 | type 类型 | key size | value size | key | value |
+-------------+-------------+-------------+--------------+-------------+--------------+
4字节 1字节 变长(最大5) 变长(最大5) 变长 变长
func EncodeLogRecordPos ¶
func GetDataFileName ¶
Types ¶
type DataFile ¶
type DataFile struct {
FileId uint32 // File ID
WriteOff int64 // 文件写到哪个位置
IoManager fio.IOManager // io 读写管理
}
DataFile represents a data file
func OpenDataFile ¶
func OpenHintFile ¶
func OpenMergeFinishedFile ¶
func OpenSeqNoFile ¶
OpenSeqNoFile opens the file that stores transaction sequence numbers
func (*DataFile) ReadLogRecord ¶
ReadLogRecord reads a LogRecord from the data file at the given offset
func (*DataFile) SetIOManager ¶
func (df *DataFile) SetIOManager(dirPath string, ioType fio.FileIOType) error
type LogRecord ¶
type LogRecord struct {
Key []byte
Value []byte
Type LogRecordType
}
LogRecord 之所以叫日志,是因为数据文件中的数据是追加写入的,类似日志的格式
type LogRecordType ¶
type LogRecordType = byte
const ( LogRecordNormal LogRecordType = iota LogRecordDeleted // 在 loadIndexFromDataFiles 的时候遇到有删除标记的,也就会删除 LogRecordTxnFinished )
type Position ¶
type Position struct {
Fid uint32 // 文件id, 将文件存储的到了哪个文件夹
Offset int64 // 偏移,数据存储到了数据文件中的哪个位置
Size uint32 // 标识数据在磁盘上的大小
}
Position 数据内存索引,主要是描述数据在磁盘上的位置
func DecodeLogRecordPos ¶
type TransactionRecord ¶
Click to show internal directories.
Click to hide internal directories.