data

package
v0.0.0-...-6438891 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeLogRecord

func EncodeLogRecord(log *LogRecord) ([]byte, int64)

func EncodeLogRecordPos

func EncodeLogRecordPos(pos *LogPos) []byte

EncodeLogRecordPos encode the pos info

func GetDataFileName

func GetDataFileName(dirPath string, fileId uint32) string

func GetLogRecordCRC

func GetLogRecordCRC(lr *LogRecord, header []byte) uint32

Types

type DataFile

type DataFile struct {
	FileId   uint32
	WriteOff int64
	Writer   driver.IOManager
	Reader   driver.IOManager
}

func OpenDataFile

func OpenDataFile(dirPath string, fileId uint32) (*DataFile, error)

OpenDataFile Open new datafile

func OpenHintFile

func OpenHintFile(dirPath string) (*DataFile, error)

OpenHintFile Open new datafile

func OpenMergeFinishedFile

func OpenMergeFinishedFile(dirPath string) (*DataFile, error)

OpenMergeFinishedFile Open new datafile

func (*DataFile) Close

func (df *DataFile) Close() error

func (*DataFile) ReadLogRecord

func (df *DataFile) ReadLogRecord(offset int64) (*LogRecord, int64, error)

func (*DataFile) Sync

func (df *DataFile) Sync() error

func (*DataFile) Write

func (df *DataFile) Write(buf []byte) error

func (*DataFile) WriteHintRecord

func (df *DataFile) WriteHintRecord(key []byte, pos *LogPos) error

WriteHintRecord write the index info to the hint file

type DataType

type DataType uint8
const (
	String DataType = iota
	Hash
	List
	ListMeta
	Set
)

type LogPos

type LogPos struct {
	Fid    uint32
	Offset int64
}

LogPos The location of the data on the disk

func DecodeLogRecordPos

func DecodeLogRecordPos(buf []byte) *LogPos

type LogRecord

type LogRecord struct {
	Key        []byte
	Value      []byte
	Type       LogRecordType
	DataType   DataType
	Expiration int64
}

type LogRecordHeader

type LogRecordHeader struct {
	RecordType LogRecordType
	DataType   DataType
	KeySize    uint32
	ValueSize  uint32
	Expiration int64
	// contains filtered or unexported fields
}

func DecodeLogRecordHeader

func DecodeLogRecordHeader(buf []byte) (*LogRecordHeader, int64)

type LogRecordType

type LogRecordType = byte
const (
	LogRecordNormal LogRecordType = iota
	LogRecordDeleted
	LogRecordTxnCommit
	LogRecordTxnRollback
	LogRecordTxnBegin
)

type TxRecord

type TxRecord struct {
	Record *LogRecord
	Pos    *LogPos
}

TxRecord Transaction data temporarily stored in memory

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL