Documentation ¶
Index ¶
- Variables
- func GetActualDatum(encoder encode.Encoder, col *table.Column, rowID int64, ...) (types.Datum, error)
- func GetAutoRecordID(d types.Datum, target *types.FieldType) int64
- func GetEncoderIncrementalID(encoder encode.Encoder, id int64) int64
- func GetSession4test(encoder encode.Encoder) sessionctx.Context
- func IsAutoIncCol(colInfo *model.ColumnInfo) bool
- func MakeRowFromKvPairs(pairs []common.KvPair) encode.Row
- func MakeRowsFromKvPairs(pairs []common.KvPair) encode.Rows
- func NewPanickingAllocators(base int64) autoid.Allocators
- func NewSessionCtx(options *encode.SessionOptions, logger log.Logger) sessionctx.Context
- func NewTableKVEncoder(config *encode.EncodingConfig, metrics *metric.Metrics) (encode.Encoder, error)
- func Row2KvPairs(row encode.Row) []common.KvPair
- func Rows2KvPairs(rows encode.Rows) []common.KvPair
- type AutoIDConverterFn
- type BaseKVEncoder
- func (e *BaseKVEncoder) EvalGeneratedColumns(record []types.Datum, cols []*table.Column) (errCol *model.ColumnInfo, err error)
- func (e *BaseKVEncoder) GetOrCreateRecord() []types.Datum
- func (e *BaseKVEncoder) IsAutoRandomCol(col *model.ColumnInfo) bool
- func (e *BaseKVEncoder) LogEvalGenExprFailed(row []types.Datum, colInfo *model.ColumnInfo, err error) error
- func (e *BaseKVEncoder) LogKVConvertFailed(row []types.Datum, j int, colInfo *model.ColumnInfo, err error) error
- func (e *BaseKVEncoder) ProcessColDatum(col *table.Column, rowID int64, inputDatum *types.Datum) (types.Datum, error)
- func (e *BaseKVEncoder) Record2KV(record, originalRow []types.Datum, rowID int64) (*Pairs, error)
- func (e *BaseKVEncoder) TruncateWarns()
- type BytesBuf
- type GeneratedCol
- type MemBuf
- func (mb *MemBuf) AllocateBuf(size int)
- func (*MemBuf) Cleanup(_ kv.StagingHandle)
- func (*MemBuf) Delete(_ kv.Key) error
- func (mb *MemBuf) Recycle(buf *BytesBuf)
- func (*MemBuf) Release(_ kv.StagingHandle)
- func (mb *MemBuf) Set(k kv.Key, v []byte) error
- func (mb *MemBuf) SetWithFlags(k kv.Key, v []byte, _ ...kv.FlagsOp) error
- func (mb *MemBuf) Size() int
- func (*MemBuf) Staging() kv.StagingHandle
- type Pairs
- type RowArrayMarshaller
- type Session
- func (*Session) BuiltinFunctionUsageInc(_ string)
- func (se *Session) Close()
- func (*Session) GetBuiltinFunctionUsage() map[string]uint32
- func (*Session) GetInfoSchema() sessionctx.InfoschemaMetaVersion
- func (se *Session) GetSessionVars() *variable.SessionVars
- func (*Session) GetStmtStats() *stmtstats.StatementStats
- func (se *Session) SetValue(key fmt.Stringer, value interface{})
- func (*Session) StmtAddDirtyTableOP(_ int, _ int64, _ kv.Handle)
- func (se *Session) TakeKvPairs() *Pairs
- func (se *Session) Txn(_ bool) (kv.Transaction, error)
- func (se *Session) Value(key fmt.Stringer) interface{}
- type TableKVDecoder
- func (t *TableKVDecoder) DecodeHandleFromIndex(indexInfo *model.IndexInfo, key, value []byte) (kv.Handle, error)
- func (*TableKVDecoder) DecodeHandleFromRowKey(key []byte) (kv.Handle, error)
- func (t *TableKVDecoder) DecodeRawRowData(h kv.Handle, value []byte) ([]types.Datum, map[int64]types.Datum, error)
- func (t *TableKVDecoder) DecodeRawRowDataAsStr(h kv.Handle, value []byte) (res string)
- func (t *TableKVDecoder) IterRawIndexKeys(h kv.Handle, rawRow []byte, fn func([]byte) error) error
- func (t *TableKVDecoder) Name() string
Constants ¶
This section is empty.
Variables ¶
var ExtraHandleColumnInfo = model.NewExtraHandleColInfo()
ExtraHandleColumnInfo is the column info of extra handle column.
Functions ¶
func GetActualDatum ¶
func GetActualDatum(encoder encode.Encoder, col *table.Column, rowID int64, inputDatum *types.Datum) (types.Datum, error)
GetActualDatum export getActualDatum function.
func GetAutoRecordID ¶
GetAutoRecordID returns the record ID for an auto-increment field. get record value for auto-increment field
See:
https://github.com/pingcap/tidb/blob/47f0f15b14ed54fc2222f3e304e29df7b05e6805/executor/insert_common.go#L781-L852
func GetEncoderIncrementalID ¶
GetEncoderIncrementalID return Auto increment id.
func GetSession4test ¶
func GetSession4test(encoder encode.Encoder) sessionctx.Context
GetSession4test is only used for test.
func IsAutoIncCol ¶
func IsAutoIncCol(colInfo *model.ColumnInfo) bool
IsAutoIncCol return true if the column is auto increment column.
func MakeRowFromKvPairs ¶
MakeRowFromKvPairs converts a KvPair slice into a Row instance. This is mainly used for testing only. The resulting Row instance should only be used for the importer backend.
func MakeRowsFromKvPairs ¶
MakeRowsFromKvPairs converts a KvPair slice into a Rows instance. This is mainly used for testing only. The resulting Rows instance should only be used for the importer backend.
func NewPanickingAllocators ¶
func NewPanickingAllocators(base int64) autoid.Allocators
NewPanickingAllocators creates a PanickingAllocator shared by all allocation types.
func NewSessionCtx ¶
func NewSessionCtx(options *encode.SessionOptions, logger log.Logger) sessionctx.Context
NewSessionCtx creates a new trimmed down Session matching the options.
func NewTableKVEncoder ¶
func NewTableKVEncoder( config *encode.EncodingConfig, metrics *metric.Metrics, ) (encode.Encoder, error)
NewTableKVEncoder creates a new tableKVEncoder.
func Row2KvPairs ¶
Row2KvPairs converts a Row instance constructed from MakeRowFromKvPairs back into a slice of KvPair. This method panics if the Row is not constructed in such way.
Types ¶
type AutoIDConverterFn ¶
AutoIDConverterFn is a function to convert auto id.
type BaseKVEncoder ¶
type BaseKVEncoder struct { GenCols []GeneratedCol SessionCtx *Session Table table.Table Columns []*table.Column AutoRandomColID int64 // convert auto id for shard rowid or auto random id base on row id generated by lightning AutoIDFn AutoIDConverterFn // the first auto-generated ID in the current encoder. // if there's no auto-generated id column or the column value is not auto-generated, it will be 0. LastInsertID uint64 // contains filtered or unexported fields }
BaseKVEncoder encodes a row into a KV pair.
func NewBaseKVEncoder ¶
func NewBaseKVEncoder(config *encode.EncodingConfig) (*BaseKVEncoder, error)
NewBaseKVEncoder creates a new BaseKVEncoder.
func (*BaseKVEncoder) EvalGeneratedColumns ¶
func (e *BaseKVEncoder) EvalGeneratedColumns(record []types.Datum, cols []*table.Column) (errCol *model.ColumnInfo, err error)
EvalGeneratedColumns evaluates the generated columns.
func (*BaseKVEncoder) GetOrCreateRecord ¶
func (e *BaseKVEncoder) GetOrCreateRecord() []types.Datum
GetOrCreateRecord returns a record slice from the cache if possible, otherwise creates a new one.
func (*BaseKVEncoder) IsAutoRandomCol ¶
func (e *BaseKVEncoder) IsAutoRandomCol(col *model.ColumnInfo) bool
IsAutoRandomCol checks if the column is auto random column.
func (*BaseKVEncoder) LogEvalGenExprFailed ¶
func (e *BaseKVEncoder) LogEvalGenExprFailed(row []types.Datum, colInfo *model.ColumnInfo, err error) error
LogEvalGenExprFailed logs the error when evaluating the generated column expression failed.
func (*BaseKVEncoder) LogKVConvertFailed ¶
func (e *BaseKVEncoder) LogKVConvertFailed(row []types.Datum, j int, colInfo *model.ColumnInfo, err error) error
LogKVConvertFailed logs the error when converting a row to KV pair failed.
func (*BaseKVEncoder) ProcessColDatum ¶
func (e *BaseKVEncoder) ProcessColDatum(col *table.Column, rowID int64, inputDatum *types.Datum) (types.Datum, error)
ProcessColDatum processes the datum of a column.
func (*BaseKVEncoder) TruncateWarns ¶
func (e *BaseKVEncoder) TruncateWarns()
TruncateWarns resets the warnings in session context.
type BytesBuf ¶
type BytesBuf struct {
// contains filtered or unexported fields
}
BytesBuf bytes buffer.
type GeneratedCol ¶
type GeneratedCol struct { // index of the column in the table Index int Expr expression.Expression }
GeneratedCol generated column info.
func CollectGeneratedColumns ¶
func CollectGeneratedColumns(se *Session, meta *model.TableInfo, cols []*table.Column) ([]GeneratedCol, error)
CollectGeneratedColumns collects all expressions required to evaluate the results of all generated columns. The returning slice is in evaluation order.
type MemBuf ¶
MemBuf used to store the data in memory.
func (*MemBuf) AllocateBuf ¶
AllocateBuf allocates a byte buffer.
func (*MemBuf) Cleanup ¶
func (*MemBuf) Cleanup(_ kv.StagingHandle)
Cleanup the resources referenced by the StagingHandle. If the changes are not published by `Release`, they will be discarded.
func (*MemBuf) Release ¶
func (*MemBuf) Release(_ kv.StagingHandle)
Release publish all modifications in the latest staging buffer to upper level.
func (*MemBuf) SetWithFlags ¶
SetWithFlags implements the kv.MemBuffer interface.
func (*MemBuf) Staging ¶
func (*MemBuf) Staging() kv.StagingHandle
Staging creates a new staging buffer.
type Pairs ¶
Pairs implements the Encoder interface.
func (*Pairs) ClassifyAndAppend ¶
func (kvs *Pairs) ClassifyAndAppend( data *encode.Rows, dataChecksum *verification.KVChecksum, indices *encode.Rows, indexChecksum *verification.KVChecksum, )
ClassifyAndAppend separates the key-value pairs into data and index key-value pairs.
type RowArrayMarshaller ¶
RowArrayMarshaller wraps a slice of types.Datum for logging the content into zap.
func (RowArrayMarshaller) MarshalLogArray ¶
func (row RowArrayMarshaller) MarshalLogArray(encoder zapcore.ArrayEncoder) error
MarshalLogArray implements the zapcore.ArrayMarshaler interface
type Session ¶
type Session struct { sessionctx.Context Vars *variable.SessionVars // contains filtered or unexported fields }
Session is a trimmed down Session type which only wraps our own trimmed-down transaction type and provides the session variables to the TiDB library optimized for Lightning.
func NewSession ¶
func NewSession(options *encode.SessionOptions, logger log.Logger) *Session
NewSession creates a new trimmed down Session matching the options.
func (*Session) BuiltinFunctionUsageInc ¶
BuiltinFunctionUsageInc implements the sessionctx.Context interface.
func (*Session) Close ¶
func (se *Session) Close()
Close implements the sessionctx.Context interface
func (*Session) GetBuiltinFunctionUsage ¶
GetBuiltinFunctionUsage returns the BuiltinFunctionUsage of current Context, which is not thread safe. Use primitive map type to prevent circular import. Should convert it to telemetry.BuiltinFunctionUsage before using.
func (*Session) GetInfoSchema ¶
func (*Session) GetInfoSchema() sessionctx.InfoschemaMetaVersion
GetInfoSchema implements the sessionctx.Context interface.
func (*Session) GetSessionVars ¶
func (se *Session) GetSessionVars() *variable.SessionVars
GetSessionVars implements the sessionctx.Context interface
func (*Session) GetStmtStats ¶
func (*Session) GetStmtStats() *stmtstats.StatementStats
GetStmtStats implements the sessionctx.Context interface.
func (*Session) StmtAddDirtyTableOP ¶
StmtAddDirtyTableOP implements the sessionctx.Context interface
func (*Session) TakeKvPairs ¶
TakeKvPairs returns the current Pairs and resets the buffer.
type TableKVDecoder ¶
type TableKVDecoder struct {
// contains filtered or unexported fields
}
TableKVDecoder is a KVDecoder that decodes the key-value pairs of a table.
func NewTableKVDecoder ¶
func NewTableKVDecoder( tbl table.Table, tableName string, options *encode.SessionOptions, logger log.Logger, ) (*TableKVDecoder, error)
NewTableKVDecoder creates a new TableKVDecoder.
func (*TableKVDecoder) DecodeHandleFromIndex ¶
func (t *TableKVDecoder) DecodeHandleFromIndex(indexInfo *model.IndexInfo, key, value []byte) (kv.Handle, error)
DecodeHandleFromIndex implements KVDecoder.DecodeHandleFromIndex.
func (*TableKVDecoder) DecodeHandleFromRowKey ¶
func (*TableKVDecoder) DecodeHandleFromRowKey(key []byte) (kv.Handle, error)
DecodeHandleFromRowKey implements KVDecoder.DecodeHandleFromRowKey.
func (*TableKVDecoder) DecodeRawRowData ¶
func (t *TableKVDecoder) DecodeRawRowData(h kv.Handle, value []byte) ([]types.Datum, map[int64]types.Datum, error)
DecodeRawRowData decodes raw row data into a datum slice and a (columnID:columnValue) map.
func (*TableKVDecoder) DecodeRawRowDataAsStr ¶
func (t *TableKVDecoder) DecodeRawRowDataAsStr(h kv.Handle, value []byte) (res string)
DecodeRawRowDataAsStr decodes raw row data into a string.
func (*TableKVDecoder) IterRawIndexKeys ¶
IterRawIndexKeys generates the raw index keys corresponding to the raw row, and then iterate them using `fn`. The input buffer will be reused.
func (*TableKVDecoder) Name ¶
func (t *TableKVDecoder) Name() string
Name implements KVDecoder.Name.