tablepacked

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Tuint uint type
	Tuint DataType = 0
	// Tenum enum type
	Tenum = 1
	// Tstring string type
	Tstring = 2
)

Variables

This section is empty.

Functions

func NewBufPool added in v0.0.13

func NewBufPool() *sync.Pool

NewBufPool init buffer data pool

func NewRowDataPool added in v0.0.13

func NewRowDataPool() *sync.Pool

NewRowDataPool init row data pool

func ReadFromBuffer

func ReadFromBuffer(buffer []byte, res *RowData) error

ReadFromBuffer read row data from buffer

func RowToStruct added in v0.0.13

func RowToStruct(dst interface{}, row *RowData, table Table) error

RowToStruct take a row and fill the struct with info

func RowsDataToJSON

func RowsDataToJSON(rowsData []*RowData, table Table, bufferPool *sync.Pool) (*wutils.Buffer, error)

RowsDataToJSON rows data to JSON

func SqliteDbPathForTableName added in v0.0.13

func SqliteDbPathForTableName(conf config.Config, tableName string) string

SqliteDbPathForTableName return the path to the sqlite folder

func StructToRow added in v0.0.13

func StructToRow(s interface{}, row *RowData, table Table) error

StructToRow take a struct and fill the row data equivalent

Types

type ColumnData

type ColumnData struct {
	// if buffer is not nil, EncodedRawValue is the buffer lenght
	// else the value can be used for value encoding (uint, int, bool, enum, float)
	EncodedRawValue uint64
	Buffer          []byte
}

ColumnData is the lowest level representation of a column in binary format

func NewNullColumnData added in v0.0.13

func NewNullColumnData() ColumnData

NewNullColumnData create null ColumnData

func (ColumnData) AppendColumnData

func (cd ColumnData) AppendColumnData(buffer []byte) []byte

AppendColumnData to buffer

func (ColumnData) DebugString added in v0.0.13

func (cd ColumnData) DebugString(d ColumnDescriptor) string

DebugString create a debug string

func (ColumnData) DebugStringRaw added in v0.0.13

func (cd ColumnData) DebugStringRaw() string

DebugStringRaw create a debug string

func (ColumnData) IsNull added in v0.0.13

func (cd ColumnData) IsNull() bool

IsNull is null ColumnData

type ColumnDescriptor

type ColumnDescriptor struct {
	Name          string
	JSONKey       string
	JSONMandatory bool
	EnumValues    []string
	NotNullable   bool
	Type          DataType
}

ColumnDescriptor describe a storage column

type DataType

type DataType uint8

DataType type of static column

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is the entry point to serve file with the table packed file format

func InitDriver

func InitDriver(conf config.Config, logger *zap.Logger, tableDescriptorRepo map[string]Table) (*Driver, error)

InitDriver init packed table dirver

func (*Driver) AppendRowData

func (d *Driver) AppendRowData(cf config.ContainerFile, rows []*RowData) error

AppendRowData append rows to a container file

func (*Driver) Archive

func (d *Driver) Archive(cf config.ContainerFile) error

Archive archive the file

func (*Driver) Close

func (d *Driver) Close() error

Close flush all pending action to file and close all files

func (*Driver) ExecRsyncCommand

func (d *Driver) ExecRsyncCommand(params map[string][]string) ([]byte, error)

ExecRsyncCommand will clean up, pause, execute the rsync command and resume

func (*Driver) Flush

func (d *Driver) Flush() (errOpsCount int, err error)

Flush all pending action to file

func (*Driver) FreeTable

func (d *Driver) FreeTable(t TableDataSlice)

FreeTable free table

func (*Driver) GetReplicator

func (d *Driver) GetReplicator() *wal.Replicator

GetReplicator get replicator

func (*Driver) ReadAllRowData

func (d *Driver) ReadAllRowData(cf config.ContainerFile) (TableDataSlice, error)

ReadAllRowData from file

func (*Driver) RemoveContent added in v0.0.13

func (d *Driver) RemoveContent(cf config.ContainerFile) error

RemoveContent append rows to a container file

type ErrBadEndingCRC

type ErrBadEndingCRC struct {
	SaneOffset int
}

ErrBadEndingCRC happened when a row has a bad CRC SaneOffset is the limit we should truncate the file to have a sane file

func (*ErrBadEndingCRC) Error

func (e *ErrBadEndingCRC) Error() string

type RowData

type RowData struct {
	Data []ColumnData
}

RowData row data

func (RowData) WriteToBuffer

func (rd RowData) WriteToBuffer(buffer []byte) []byte

WriteToBuffer write row data to buffer

type Table

type Table struct {
	Name    string
	Columns []ColumnDescriptor
}

Table contains columns

func UnmarshallJSONTableDescriptor added in v0.0.13

func UnmarshallJSONTableDescriptor(path string) (*Table, error)

UnmarshallJSONTableDescriptor unmarshall atable descriptor from a json file

func (Table) ParseJSON

func (t Table) ParseJSON(buffer []byte) (RowData, error)

ParseJSON parse json to row data

type TableData

type TableData struct {
	Data []*RowData
	// contains filtered or unexported fields
}

TableData table data

func ReadAllRowDataFromFile

func ReadAllRowDataFromFile(cf config.ContainerFile, wal *wal.WAL, rowDataPool *sync.Pool, bufferPool *sync.Pool) (*TableData, error)

ReadAllRowDataFromFile append row data

func ReadAllRowDataFromFileBuffer added in v0.0.13

func ReadAllRowDataFromFileBuffer(fileBuf *wutils.Buffer, rowDataPool *sync.Pool) (*TableData, error)

ReadAllRowDataFromFileBuffer append row data

func ReadAllRowDataFromFileCorruptSafe

func ReadAllRowDataFromFileCorruptSafe(cf config.ContainerFile, wal *wal.WAL, rowDataPool *sync.Pool, bufferPool *sync.Pool) (*TableData, error)

ReadAllRowDataFromFileCorruptSafe append row data and repair file if corruption happened

func (*TableData) Refc

func (t *TableData) Refc() uint

Refc count

type TableDataSlice

type TableDataSlice struct {
	// contains filtered or unexported fields
}

TableDataSlice table data slice

func InitTableDataSlice

func InitTableDataSlice(t *TableData) TableDataSlice

InitTableDataSlice from table data

func (TableDataSlice) AllRows

func (tds TableDataSlice) AllRows() []*RowData

AllRows get all rows in the slice

func (TableDataSlice) Len

func (tds TableDataSlice) Len() int

Len len of the table data slice

func (TableDataSlice) Release

func (tds TableDataSlice) Release()

Release rfc count for this table data

func (TableDataSlice) Retain

func (tds TableDataSlice) Retain()

Retain rfc count for this table data

func (TableDataSlice) Row

func (tds TableDataSlice) Row(i int) *RowData

Row get row at index

Jump to

Keyboard shortcuts

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