Documentation
¶
Index ¶
- Constants
- func CutIndexKey(key kv.Key, colIDs []int64) (values map[int64][]byte, b []byte, err error)
- func CutIndexKeyNew(key kv.Key, length int) (values [][]byte, b []byte, err error)
- func CutIndexPrefix(key kv.Key) []byte
- func CutRowKeyPrefix(key kv.Key) []byte
- func CutRowNew(data []byte, colIDs map[int64]int) ([][]byte, error)
- func DecodeColumnValue(data []byte, ft *types.FieldType, loc *time.Location) (types.Datum, error)
- func DecodeIndexHandle(key, value []byte, colsLen int, pkTp *types.FieldType) (int64, error)
- func DecodeIndexKV(key, value []byte, colsLen int, hdStatus HandleStatus, ...) ([][]byte, error)
- func DecodeIndexKey(key kv.Key) (tableID int64, indexID int64, indexValues []string, err error)
- func DecodeIndexKeyPrefix(key kv.Key) (tableID int64, indexID int64, indexValues []byte, err error)
- func DecodeIndexValueAsHandle(data []byte) (int64, error)
- func DecodeKeyHead(key kv.Key) (tableID int64, indexID int64, isRecordKey bool, err error)
- func DecodeMetaKey(ek kv.Key) (key []byte, field []byte, err error)
- func DecodeRecordKey(key kv.Key) (tableID int64, handle int64, err error)
- func DecodeRow(b []byte, cols map[int64]*types.FieldType, loc *time.Location) (map[int64]types.Datum, error)
- func DecodeRowKey(key kv.Key) (int64, error)
- func DecodeRowWithMap(b []byte, cols map[int64]*types.FieldType, loc *time.Location, ...) (map[int64]types.Datum, error)
- func DecodeRowWithMapNew(b []byte, cols map[int64]*types.FieldType, loc *time.Location, ...) (map[int64]types.Datum, error)
- func DecodeTableID(key kv.Key) int64
- func EncodeIndexSeekKey(tableID int64, idxID int64, encodedValue []byte) kv.Key
- func EncodeOldRow(sc *stmtctx.StatementContext, row []types.Datum, colIDs []int64, valBuf []byte, ...) ([]byte, error)
- func EncodeRecordKey(recordPrefix kv.Key, h int64) kv.Key
- func EncodeRow(sc *stmtctx.StatementContext, row []types.Datum, colIDs []int64, valBuf []byte, ...) ([]byte, error)
- func EncodeRowKey(tableID int64, encodedHandle []byte) kv.Key
- func EncodeRowKeyWithHandle(tableID int64, handle int64) kv.Key
- func EncodeTableIndexPrefix(tableID, idxID int64) kv.Key
- func EncodeTablePrefix(tableID int64) kv.Key
- func EncodeValue(sc *stmtctx.StatementContext, b []byte, raw types.Datum) ([]byte, error)
- func GenTableIndexPrefix(tableID int64) kv.Key
- func GenTablePrefix(tableID int64) kv.Key
- func GenTableRecordPrefix(tableID int64) kv.Key
- func GetTableHandleKeyRange(tableID int64) (startKey, endKey []byte)
- func GetTableIndexKeyRange(tableID, indexID int64) (startKey, endKey []byte)
- func IsIndexKey(k []byte) bool
- func IsUntouchedIndexKValue(k, v []byte) bool
- func ReplaceRecordKeyTableID(buf []byte, tableID int64) []byte
- func TablePrefix() []byte
- func TruncateToRowKeyLen(key kv.Key) kv.Key
- func UnflattenDatums(datums []types.Datum, fts []*types.FieldType, loc *time.Location) ([]types.Datum, error)
- type HandleStatus
Constants ¶
const ( // RecordRowKeyLen is public for calculating avgerage row size. RecordRowKeyLen = prefixLen + idLen /*handle*/ // MaxOldEncodeValueLen is the maximum len of the old encoding of index value. MaxOldEncodeValueLen = 9 )
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 ¶
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 ¶
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 CutRowKeyPrefix ¶
CutRowKeyPrefix cuts the row key prefix.
func CutRowNew ¶
CutRowNew cuts encoded row into byte slices and return columns' byte slice. Row layout: colID1, value1, colID2, value2, .....
func DecodeColumnValue ¶
DecodeColumnValue decodes data to a Datum according to the column info.
func DecodeIndexHandle ¶
DecodeIndexHandle uses to decode the handle from index key/value.
func DecodeIndexKV ¶
func DecodeIndexKV(key, value []byte, colsLen int, hdStatus HandleStatus, columns []rowcodec.ColInfo) ([][]byte, error)
DecodeIndexKV uses to decode index key values.
func DecodeIndexKey ¶
DecodeIndexKey decodes the key and gets the tableID, indexID, indexValues.
func DecodeIndexKeyPrefix ¶
DecodeIndexKeyPrefix decodes the key and gets the tableID, indexID, indexValues.
func DecodeIndexValueAsHandle ¶
DecodeIndexValueAsHandle uses to decode index value as handle id.
func DecodeKeyHead ¶
DecodeKeyHead decodes the key's head and gets the tableID, indexID. isRecordKey is true when is a record key.
func DecodeMetaKey ¶
DecodeMetaKey decodes the key and get the meta key and meta field.
func DecodeRecordKey ¶
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 ¶
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 DecodeRowWithMapNew ¶
func DecodeRowWithMapNew(b []byte, cols map[int64]*types.FieldType, loc *time.Location, row map[int64]types.Datum) (map[int64]types.Datum, error)
DecodeRowWithMapNew decode a row to datum map.
func DecodeTableID ¶
DecodeTableID decodes the table ID of the key, if the key is not table key, returns 0.
func EncodeIndexSeekKey ¶
EncodeIndexSeekKey encodes an index value to kv.Key.
func EncodeOldRow ¶
func EncodeOldRow(sc *stmtctx.StatementContext, row []types.Datum, colIDs []int64, valBuf []byte, values []types.Datum) ([]byte, error)
EncodeOldRow 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 EncodeOldRow allocates temporary bufs. If you pass valBuf and values as nil, EncodeOldRow will allocate it.
func EncodeRecordKey ¶
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, e *rowcodec.Encoder) ([]byte, error)
EncodeRow encode row data and column ids into a slice of byte. 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 EncodeRowKey ¶
EncodeRowKey encodes the table id and record handle into a kv.Key
func EncodeRowKeyWithHandle ¶
EncodeRowKeyWithHandle encodes the table id, row handle into a kv.Key
func EncodeTableIndexPrefix ¶
EncodeTableIndexPrefix encodes index prefix with tableID and idxID.
func EncodeTablePrefix ¶
EncodeTablePrefix encodes table prefix with table ID.
func EncodeValue ¶
EncodeValue encodes a go value to bytes.
func GenTableIndexPrefix ¶
GenTableIndexPrefix composes index prefix with tableID: "t[tableID]_i".
func GenTablePrefix ¶
GenTablePrefix composes table record and index prefix: "t[tableID]".
func GenTableRecordPrefix ¶
GenTableRecordPrefix composes record prefix with tableID: "t[tableID]_r".
func GetTableHandleKeyRange ¶
GetTableHandleKeyRange returns table handle's key range with tableID.
func GetTableIndexKeyRange ¶
GetTableIndexKeyRange returns table index's key range with tableID and indexID.
func IsIndexKey ¶
IsIndexKey is used to check whether the key is an index key.
func IsUntouchedIndexKValue ¶
IsUntouchedIndexKValue uses to check whether the key is index key, and the value is untouched, since the untouched index key/value is no need to commit.
func ReplaceRecordKeyTableID ¶
ReplaceRecordKeyTableID replace the tableID in the recordKey buf.
func TruncateToRowKeyLen ¶
TruncateToRowKeyLen truncates the key to row key length if the key is longer than row key.
Types ¶
type HandleStatus ¶
type HandleStatus int
HandleStatus is the handle status in index.
const ( // HandleNotExists means no need to decode handle value when DecodeIndexKV. HandleNotExists HandleStatus = iota // HandleIsSigned means decode handle value as int64 when DecodeIndexKV. HandleIsSigned // HandleIsUnsigned means decode handle value as uint64 when DecodeIndexKV. HandleIsUnsigned )