tablecodec

package
v2.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 12 Imported by: 2,177

Documentation

Index

Constants

View Source
const TableSplitKeyLen = 1 + idLen

TableSplitKeyLen is the length of key 't{table_id}' which is used for table split.

Variables

This section is empty.

Functions

func CutIndexKey

func CutIndexKey(key kv.Key, colIDs []int64) (values map[int64][]byte, b []byte, err error)

CutIndexKey cuts encoded index key into colIDs to bytes slices map. The returned value b is the remaining bytes of the key which would be empty if it is unique index or handle data if it is non-unique index.

func CutIndexKeyNew

func CutIndexKeyNew(key kv.Key, length int) (values [][]byte, b []byte, err error)

CutIndexKeyNew cuts encoded index key into colIDs to bytes slices. The returned value b is the remaining bytes of the key which would be empty if it is unique index or handle data if it is non-unique index.

func CutIndexPrefix

func CutIndexPrefix(key kv.Key) []byte

CutIndexPrefix cuts the index prefix.

func CutRowKeyPrefix

func CutRowKeyPrefix(key kv.Key) []byte

CutRowKeyPrefix cuts the row key prefix.

func CutRowNew

func CutRowNew(data []byte, colIDs map[int64]int) ([][]byte, error)

CutRowNew cuts encoded row into byte slices and return columns' byte slice. Row layout: colID1, value1, colID2, value2, .....

func DecodeColumnValue

func DecodeColumnValue(data []byte, ft *types.FieldType, loc *time.Location) (types.Datum, error)

DecodeColumnValue decodes data to a Datum according to the column info.

func DecodeIndexKey

func DecodeIndexKey(key kv.Key) (tableID int64, indexID int64, indexValues []string, err error)

DecodeIndexKey decodes the key and gets the tableID, indexID, indexValues.

func DecodeKeyHead

func DecodeKeyHead(key kv.Key) (tableID int64, indexID int64, isRecordKey bool, err error)

DecodeKeyHead decodes the key's head and gets the tableID, indexID. isRecordKey is true when is a record key.

func DecodeRecordKey

func DecodeRecordKey(key kv.Key) (tableID int64, handle int64, err error)

DecodeRecordKey decodes the key and gets the tableID, handle.

func DecodeRow

func DecodeRow(b []byte, cols map[int64]*types.FieldType, loc *time.Location) (map[int64]types.Datum, error)

DecodeRow decodes a byte slice into datums. Row layout: colID1, value1, colID2, value2, .....

func DecodeRowKey

func DecodeRowKey(key kv.Key) (int64, error)

DecodeRowKey decodes the key and gets the handle.

func DecodeRowWithMap

func DecodeRowWithMap(b []byte, cols map[int64]*types.FieldType, loc *time.Location, row map[int64]types.Datum) (map[int64]types.Datum, error)

DecodeRowWithMap decodes a byte slice into datums with a existing row map. Row layout: colID1, value1, colID2, value2, .....

func DecodeTableID

func DecodeTableID(key kv.Key) int64

DecodeTableID decodes the table ID of the key, if the key is not table key, returns 0.

func EncodeIndexSeekKey

func EncodeIndexSeekKey(tableID int64, idxID int64, encodedValue []byte) kv.Key

EncodeIndexSeekKey encodes an index value to kv.Key.

func EncodeRecordKey

func EncodeRecordKey(recordPrefix kv.Key, h int64) kv.Key

EncodeRecordKey encodes the recordPrefix, row handle into a kv.Key.

func EncodeRow

func EncodeRow(sc *stmtctx.StatementContext, row []types.Datum, colIDs []int64, valBuf []byte, values []types.Datum) ([]byte, error)

EncodeRow encode row data and column ids into a slice of byte. Row layout: colID1, value1, colID2, value2, ..... valBuf and values pass by caller, for reducing EncodeRow allocates tempory bufs. If you pass valBuf and values as nil, EncodeRow will allocate it.

func EncodeRowKey

func EncodeRowKey(tableID int64, encodedHandle []byte) kv.Key

EncodeRowKey encodes the table id and record handle into a kv.Key

func EncodeRowKeyWithHandle

func EncodeRowKeyWithHandle(tableID int64, handle int64) kv.Key

EncodeRowKeyWithHandle encodes the table id, row handle into a kv.Key

func EncodeTableIndexPrefix

func EncodeTableIndexPrefix(tableID, idxID int64) kv.Key

EncodeTableIndexPrefix encodes index prefix with tableID and idxID.

func EncodeTablePrefix

func EncodeTablePrefix(tableID int64) kv.Key

EncodeTablePrefix encodes table prefix with table ID.

func EncodeValue

func EncodeValue(sc *stmtctx.StatementContext, raw types.Datum) ([]byte, error)

EncodeValue encodes a go value to bytes.

func GenTableIndexPrefix

func GenTableIndexPrefix(tableID int64) kv.Key

GenTableIndexPrefix composes index prefix with tableID: "t[tableID]_i".

func GenTablePrefix

func GenTablePrefix(tableID int64) kv.Key

GenTablePrefix composes table record and index prefix: "t[tableID]".

func GenTableRecordPrefix

func GenTableRecordPrefix(tableID int64) kv.Key

GenTableRecordPrefix composes record prefix with tableID: "t[tableID]_r".

func GetTableHandleKeyRange

func GetTableHandleKeyRange(tableID int64) (startKey, endKey []byte)

GetTableHandleKeyRange returns table handle's key range with tableID.

func GetTableIndexKeyRange

func GetTableIndexKeyRange(tableID, indexID int64) (startKey, endKey []byte)

GetTableIndexKeyRange returns table index's key range with tableID and indexID.

func ReplaceRecordKeyTableID

func ReplaceRecordKeyTableID(buf []byte, tableID int64) []byte

ReplaceRecordKeyTableID replace the tableID in the recordKey buf.

func TablePrefix

func TablePrefix() []byte

TablePrefix returns table's prefix 't'.

func TruncateToRowKeyLen

func TruncateToRowKeyLen(key kv.Key) kv.Key

TruncateToRowKeyLen truncates the key to row key length if the key is longer than row key.

func UnflattenDatums

func UnflattenDatums(datums []types.Datum, fts []*types.FieldType, loc *time.Location) ([]types.Datum, error)

UnflattenDatums converts raw datums to column datums.

Types

This section is empty.

Jump to

Keyboard shortcuts

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