tablecodec

package
v0.0.0-...-3903214 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeColumnValue

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

func DecodeIndexKey

func DecodeIndexKey(key []byte, cols []*types.FieldType, pks []*types.FieldType,
	loc *time.Location) (int64, int64, []types.Datum, []types.Datum, error)

DecodeUniqIndexKey decodes the key and gets the tableID, indexID, column values, pk values.

func DecodeRecordKey

func DecodeRecordKey(key []byte, cols []*types.FieldType,
	loc *time.Location) (int64, []types.Datum, int64, []byte, error)

DecodeRecordKey decodes the key and gets the tableID, primaryKey, columnFamilyID,columnID columnID may not exist, return -1.

func DecodeRowFlexible

func DecodeRowFlexible(sc *stmtctx.StatementContext, b []byte) (map[string]types.Datum, byte, error)

func DecodeRowHigh

func DecodeRowHigh(sc *stmtctx.StatementContext, data []byte, ft *types.FieldType,
	loc *time.Location) (types.Datum, error)

func DecodeRowWide

func DecodeRowWide(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 DecodeUniqIndexKey

func DecodeUniqIndexKey(key []byte, cols []*types.FieldType,
	loc *time.Location) (int64, int64, []types.Datum, error)

DecodeUniqIndexKey decodes the key and gets the tableID, indexID, column values.

func EncodeIndex

func EncodeIndex(sc *stmtctx.StatementContext, tableID, idxID int64,
	values, primaryKey []types.Datum) ([]byte, error)

Format: v(TableID),v(IndexPrefix),v(IndexID),m(ColumnValue1)...m(ColumnValueN),v(PrimaryKeyPrefix),m(PrimaryKey)

func EncodeIndexPrefix

func EncodeIndexPrefix(sc *stmtctx.StatementContext, tableID, idxID int64,
	values []types.Datum) ([]byte, error)

func EncodeIndexUnique

func EncodeIndexUnique(sc *stmtctx.StatementContext, tableID, idxID int64,
	values []types.Datum) ([]byte, error)

Format: key: v(TableID),v(IndexPrefix),v(IndexID),m(ColumnValue1),m(ColumnValue2)...

func EncodeKeyTablePrefix

func EncodeKeyTablePrefix(tableID int64) []byte

func EncodePkCF

func EncodePkCF(key kv.Key, columnFamilyID int64) kv.Key

func EncodePkCFColumn

func EncodePkCFColumn(key kv.Key, column []byte) kv.Key

func EncodePkCFWithColumn

func EncodePkCFWithColumn(key kv.Key, columnFamilyID int64, column []byte) kv.Key

func EncodePkPrefix

func EncodePkPrefix(key kv.Key) kv.Key

func EncodePrimaryKey

func EncodePrimaryKey(sc *stmtctx.StatementContext, primaryKey []types.Datum) ([]byte, error)

func EncodeRecordKeyHigh

func EncodeRecordKeyHigh(sc *stmtctx.StatementContext, tableID int64,
	primaryKey []types.Datum, columnFamilyID int64, columnName []byte) ([]byte, error)

Format: v(TableID),v(PrimaryKeyPrefix),m(PrimaryKey),v(ColumnFamilyPrefix),v(ColumnFamilyID),v(ColumnName)

func EncodeRecordKeyWide

func EncodeRecordKeyWide(sc *stmtctx.StatementContext, tableID int64,
	primaryKey []types.Datum, columnFamilyID int64) ([]byte, error)

Format: v(TableID),v(PrimaryKeyPrefix),m(PrimaryKey),v(ColumnFamilyPrefix),v(ColumnFamilyID)

func EncodeRecordKeyWideWithEncodedPK

func EncodeRecordKeyWideWithEncodedPK(tableID int64,
	encodedPK []byte, columnFamilyID int64) []byte

func EncodeRecordPrimaryKey

func EncodeRecordPrimaryKey(sc *stmtctx.StatementContext, tableID int64,
	primaryKey []types.Datum) ([]byte, error)

EncodeRecordPrimaryKey Format: v(TableID),v(PrimaryKeyPrefix),m(PrimaryKey)

func EncodeRecordPrimaryKeyCFPrefix

func EncodeRecordPrimaryKeyCFPrefix(sc *stmtctx.StatementContext, tableID int64,
	primaryKey []types.Datum, columnFamilyID int64) ([]byte, error)

EncodeRecordPrimaryKeyCFPrefix Format: v(TableID),v(PrimaryKeyPrefix),m(PrimaryKey),v

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 temporary bufs. If you pass valBuf and values as nil, EncodeRow will allocate it.

func EncodeRowFlexible

func EncodeRowFlexible(sc *stmtctx.StatementContext, row map[string]types.Datum,
	valBuf []byte, values []types.Datum) ([]byte, error)

EncodeRowFlexible encode row data and column name into a slice of byte. Row layout: colName1, value1, colName2, value2, ..... valBuf and values pass by caller, for reducing EncodeRow allocates temporary bufs. If you pass valBuf and values as nil, EncodeRow will allocate it.

func EncodeRowHigh

func EncodeRowHigh(sc *stmtctx.StatementContext, value types.Datum, valBuf []byte) ([]byte, error)

EncodeRowHigh encode the value in `High Layout`.

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 ExtractEncodedHighColumnName

func ExtractEncodedHighColumnName(key []byte, sc *stmtctx.StatementContext, tableID int64,
	primaryKey []types.Datum, columnFamilyID int64) (string, error)

func ExtractEncodedPrimaryKey

func ExtractEncodedPrimaryKey(key kv.Key) []byte

ExtractEncodedPrimaryKey extract primary key raw bytes from encoded key. Used for constructing index, avoid to encode primary key one more time.

func ExtractEncodedPrimaryKeyCFPrefix

func ExtractEncodedPrimaryKeyCFPrefix(key kv.Key) []byte

Only for EncodeRecordPrimaryKeyCFPrefix !!!!

func GenIndexKeyPrefix

func GenIndexKeyPrefix(tableID int64) kv.Key

func GenRecordKeyPrefix

func GenRecordKeyPrefix(tableID int64) kv.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