Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeKey(key []byte) ([]byte, uint64)
- func EncodeKey(key []byte, tranNo uint64) []byte
- func EncodeLogRecord(lr *LogRecord) ([]byte, int64)
- func EncodeLogRecordPosition(lrp *LogRecordPosition) []byte
- func GetDataFilePath(directory string, fileID uint32) string
- func WriteHintRecord(hintFile *DataFile, key []byte, lrp *LogRecordPosition) error
- type DataFile
- func (df *DataFile) Close() error
- func (df *DataFile) Path() string
- func (df *DataFile) ReadLogRecord(offset int64) (*LogRecord, int64, error)
- func (df *DataFile) SetIOHandler(ioHandlerType io_handler.IOHandlerType) error
- func (df *DataFile) Size() (int64, error)
- func (df *DataFile) Sync() error
- func (df *DataFile) Write(data []byte) error
- type LogRecord
- type LogRecordPosition
- type LogRecordType
- type TransactionRecord
Constants ¶
const ( // A fixed name suffix of every single data file in the DB engine DataFileNameSuffix = ".data" HintFileName = "hint-index" MergedFileName = "merged" TranNoFileName = "tran-no" )
Variables ¶
var ErrInvalidCRC = errors.New("invalid CRC value. Maybe the log record was corrupted")
Functions ¶
func DecodeKey ¶
DecodeKey decodes the given key to get another record and a transaction serial number
Usually the given key has been encoded.
As an output, the decoded key is the one of a certain log record.
func EncodeKey ¶
EncodeKey encodes a key and a transaction serial number
The given key is usually from a log record
func EncodeLogRecord ¶
EncodeLogRecord encodes a log record
func EncodeLogRecordPosition ¶
func EncodeLogRecordPosition(lrp *LogRecordPosition) []byte
EncodeLogRecordPosition encodes a LogRecordPosition into a byte array
func GetDataFilePath ¶
func WriteHintRecord ¶
func WriteHintRecord(hintFile *DataFile, key []byte, lrp *LogRecordPosition) error
WriteHintRecord writes a LogRecordPosition to a hint file
Types ¶
type DataFile ¶
type DataFile struct { FileID uint32 // FileID identifies of a data file WriteOffset int64 // WriteOffset indicates the offset of the written data in a data file // contains filtered or unexported fields }
DataFile represents a data file in a DB engine instance
func OpenDataFile ¶
func OpenDataFile( directory string, fileID uint32, ioHandlerType io_handler.IOHandlerType, ) (*DataFile, error)
OpenDataFile opens a data file
func OpenHintFile ¶
OpenHintFile opens a hint file
func OpenMergedFile ¶
OpenMergedFile opens a merged file
func OpenTranNoFile ¶
OpenTranNoFile opens a file about a transaction serial number
func (*DataFile) ReadLogRecord ¶
ReadLogRecord reads single log record by given offset in a data file
func (*DataFile) SetIOHandler ¶
func (df *DataFile) SetIOHandler(ioHandlerType io_handler.IOHandlerType) error
SetIOHandler switches I/O handler of a data file
type LogRecord ¶
type LogRecord struct { Key []byte // Key Value []byte // Value Type LogRecordType // Type indicates whether a log record is unusable (deleted) or not }
LogRecord represents a log record in a data file
type LogRecordPosition ¶
type LogRecordPosition struct { // ID of the data file where the log record is stored in FileID uint32 // Offset of the log record in the data file Offset int64 // Size of the log record (uint: Byte) Size uint32 }
LogRecordPosition represents a position of a LogRecord A position of a LogRecord stores in an in-memory index
func DecodeLogRecordPosition ¶
func DecodeLogRecordPosition(buffer []byte) *LogRecordPosition
DecodeLogRecordPosition decodes a byte array into a DecodeLogRecordPosition
type LogRecordType ¶
type LogRecordType = byte
LogRecordType types of log records
const ( NormalLogRecord LogRecordType = iota + 1 // NormalLogRecord indicates that a log record is normal to read, update or delete DeletedLogRecord // DeletedLogRecord indicates that a log record is deleted and unusable TransactionFinishedLogRecord // TransactionFinishedLogRecord indicates that a Transaction is finished )
type TransactionRecord ¶
type TransactionRecord struct { Log *LogRecord // a log record Position *LogRecordPosition // position of the log record }
TransactionRecord