wal

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(fp *os.File, targetOffset int64, buffer []byte) (result []byte, newOffset int64, err error)

func ReadStatus

func ReadStatus(filePtr *os.File) (fileStatus FileStatusEnum, replayStatus ReplayStateEnum, OwningInstanceID int64, err error)

Types

type FileStatusEnum

type FileStatusEnum int8
const (
	Invalid FileStatusEnum = iota
	OPEN
	CLOSED
)

type OffsetIndexBuffer

type OffsetIndexBuffer []byte

func (OffsetIndexBuffer) Index

func (b OffsetIndexBuffer) Index() int64

Index indicates the number of timeframes before this data from Jan 1st, 00:00:00 of the year. Note that Index starts from 1 (unless the timeframe is 1D). e.g. if timeframe=1Min and the time of the record = Jan 2nd, 03:04:05, then its index is 1625 because it's 1day 3hour 4min (=1624min) from Jan 1st, 00:00:00.

func (OffsetIndexBuffer) IndexAndPayload

func (b OffsetIndexBuffer) IndexAndPayload() []byte

func (OffsetIndexBuffer) Offset

func (b OffsetIndexBuffer) Offset() int64

Offset is the byte offset from the head of the file to write the record. offset = (index-1)*int64(recordSize) + FileHeadersSize. used to seek the point to write the record to the file.

func (OffsetIndexBuffer) Payload

func (b OffsetIndexBuffer) Payload() []byte

Payload can be multiple rows data that have the same index, in case of VariableLength record type.

type ReplayStateEnum

type ReplayStateEnum int8
const (
	Invalid2 ReplayStateEnum = iota
	NOTREPLAYED
	REPLAYED
	REPLAYINPROCESS
)

type ShortReadError

type ShortReadError string

func (ShortReadError) Error

func (msg ShortReadError) Error() string

type WTSet

type WTSet struct {
	// Direct or Indirect IO (for variable or fixed length records)
	RecordType io.EnumRecordType
	// FilePath is an absolute path of the WAL file. The string is ASCII encoded without a trailing null
	FilePath string
	// Length of each data element in this set in bytes, excluding the index
	// In case of VARIABLE recordType, this value is always 24.
	// (=Index(8byte), Offset(8byte), DataLen of the the variable length records(8byte))
	DataLen int
	// Used only in case of VARIABLE recordType.
	// (The sum of field lengths in elementTypes without Epoch column) + 4 bytes(for intervalTicks)
	VarRecLen int
	// Data bytes
	Buffer OffsetIndexBuffer
	// Data Shape with Epoch Column
	DataShapes []io.DataShape
}

func NewWTSet

func NewWTSet(
	recordType io.EnumRecordType, filePath string, dataLen, varRecLen int, data OffsetIndexBuffer, dataShapes []io.DataShape,
) WTSet

type WriteCommand

type WriteCommand struct {
	RecordType io.EnumRecordType
	WALKeyPath string
	// VarRecLen is used only in case of VARIABLE recordType.
	// (The sum of field lengths in elementTypes without Epoch column) + 4 bytes(for intervalTicks)
	VarRecLen     int
	Offset, Index int64
	// Data can be for multiple row records.
	// If the record type is FIXED, one row data is the series of columns without Epoch column.
	// If it's VARIABLE, one row data is the series of columns without Epoch Column, but with IntervalTick(4byte).
	Data []byte
	// DataShapes with Epoch column
	DataShapes []io.DataShape
}

WriteCommand is a write request for WriteAheadLog (WAL). One WriteCommand can have multiple row records that have the same index, in case of VariableLength record type.

Jump to

Keyboard shortcuts

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