Documentation
¶
Index ¶
- Variables
- func ReadInt(b []byte, offset uint32) uint32
- type Codec
- type Metadata
- type V1
- func (v V1) GetHeaderSize() uint32
- func (v V1) GetIdxExtension() string
- func (v V1) GetRecordSize(buf []byte, startFileOffset uint32) (payloadSize uint32, err error)
- func (v V1) GetTxnExtension() string
- func (v V1) ReadHeaderWithValidation(buf []byte, startFileOffset uint32) (payloadSize uint32, previousCrc uint32, payloadCrc uint32, err error)
- func (v V1) ReadRecordWithValidation(buf []byte, startFileOffset uint32) (payload []byte, err error)
- func (V1) WriteRecord(buf []byte, startOffset uint32, _ uint32, payload []byte) (recordSize uint32, payloadCrc uint32)
- type V2
- func (v V2) GetHeaderSize() uint32
- func (v V2) GetIdxExtension() string
- func (v V2) GetRecordSize(buf []byte, startFileOffset uint32) (uint32, error)
- func (v V2) GetTxnExtension() string
- func (v V2) ReadHeaderWithValidation(buf []byte, startFileOffset uint32) (payloadSize uint32, previousCrc uint32, payloadCrc uint32, err error)
- func (v V2) ReadRecordWithValidation(buf []byte, startFileOffset uint32) (payload []byte, err error)
- func (V2) WriteRecord(buf []byte, startOffset uint32, previousCrc uint32, payload []byte) (recordSize uint32, payloadCrc uint32)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOffsetOutOfBounds = errors.New("oxia: offset out of bounds") ErrEmptyPayload = errors.New("oxia: empty payload") ErrDataCorrupted = errors.New("oxia: data corrupted") )
View Source
var SupportedCodecs = []Codec{latestCodec, v1} // the latest codec should be always first element
Functions ¶
Types ¶
type Codec ¶
type Codec interface {
// GetHeaderSize returns the fixed size of the header in bytes
// for each record. This value is used to understand where the
// payload starts after the header.
GetHeaderSize() uint32
// GetIdxExtension returns the index file extension. THis value is used to help compatible with
// multiple versions for index file.
GetIdxExtension() string
// GetTxnExtension returns the txn file extension. THis value is used to help compatible with
// multiple versions for txn file.
GetTxnExtension() string
// GetRecordSize returns the size of the record in bytes which includes the header.
GetRecordSize(buf []byte, startFileOffset uint32) (payloadSize uint32, err error)
// ReadRecordWithValidation reads a record starting at the specified
// file offset in the buffer. It also validates the record's integrity
// (e.g., CRC checks) before returning the payload.
//
// Parameters:
// - buf: The buffer containing the data to read from.
// - startFileOffset: The file offset to start reading from.
//
// Returns:
// - payload: The actual data (payload) of the record.
// - err: Error if any issues occur during reading or validation.
ReadRecordWithValidation(buf []byte, startFileOffset uint32) (payload []byte, err error)
// ReadHeaderWithValidation reads the header of a record at the specified
// offset and validates the integrity of the header data (e.g., CRC checks).
//
// Parameters:
// - buf: The buffer containing the data to read from.
// - startFileOffset: The file offset to start reading from.
//
// Returns:
// - payloadSize: The size of the payload.
// - previousCrc: The CRC value of the previous record.
// - payloadCrc: The CRC value of the current payload.
// - err: Error if any issues occur during reading or validation.
ReadHeaderWithValidation(buf []byte, startFileOffset uint32) (payloadSize uint32, previousCrc uint32, payloadCrc uint32, err error)
// WriteRecord writes a record to the buffer, starting at the specified
// offset, and includes a header with metadata like CRC.
//
// Parameters:
// - buf: The buffer where the record will be written.
// - startFileOffset: The file offset to start reading from.
// - previousCrc: The CRC value of the previous record to maintain consistency.
// - payload: The actual data (payload) to write as part of the record.
//
// Returns:
// - recordSize: The total size of the written record, including the header.
// - payloadCrc: The CRC value of the written payload.
WriteRecord(buf []byte, startFileOffset uint32, previousCrc uint32, payload []byte) (recordSize uint32, payloadCrc uint32)
}
type V1 ¶
type V1 struct {
Metadata
}
func (V1) GetHeaderSize ¶
func (V1) GetIdxExtension ¶
func (V1) GetRecordSize ¶
func (V1) GetTxnExtension ¶
func (V1) ReadHeaderWithValidation ¶
func (V1) ReadRecordWithValidation ¶
type V2 ¶
type V2 struct {
Metadata
}
func (V2) GetHeaderSize ¶
func (V2) GetIdxExtension ¶
func (V2) GetRecordSize ¶
func (V2) GetTxnExtension ¶
func (V2) ReadHeaderWithValidation ¶
func (V2) ReadRecordWithValidation ¶
Click to show internal directories.
Click to hide internal directories.