Documentation ¶
Index ¶
- Variables
- func ClearRow(row encode.Row)
- 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 IsAutoIncCol(colInfo *model.ColumnInfo) bool
- func MakeRowFromKvPairs(pairs []common.KvPair) encode.Row
- func MakeRowsFromKvPairs(pairs []common.KvPair) encode.Rows
- func NewPanickingAllocators(sepAutoInc bool, base int64) autoid.Allocators
- 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) AddRecord(record []types.Datum) (kv.Handle, error)
- 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) TableAllocators() autoid.Allocators
- func (e *BaseKVEncoder) TableMeta() *model.TableInfo
- func (e *BaseKVEncoder) TruncateWarns()
- type BytesBuf
- type GeneratedCol
- type GroupedPairs
- type MemBuf
- func (mb *MemBuf) AllocateBuf(size int)
- func (*MemBuf) Cleanup(_ kv.StagingHandle)
- func (*MemBuf) Delete(_ kv.Key) error
- func (mb *MemBuf) GetLocal(ctx context.Context, key []byte) ([]byte, 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 (s *Session) Close()
- func (s *Session) GetColumnSize(tblID int64) (ret map[int64]int64)
- func (s *Session) GetExprCtx() exprctx.ExprContext
- func (s *Session) GetTableCtx() tblctx.MutateContext
- func (s *Session) SetUserVarVal(name string, dt types.Datum)
- func (s *Session) TakeKvPairs() *Pairs
- func (s *Session) Txn() kv.Transaction
- func (s *Session) UnsetUserVar(varName string)
- 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 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(sepAutoInc bool, base int64) autoid.Allocators
NewPanickingAllocators creates a PanickingAllocator shared by all allocation types. we use this to collect the max id(either _tidb_rowid or auto_increment id or auto_random) used during import, and we will use this info to do ALTER TABLE xxx AUTO_RANDOM_BASE or AUTO_INCREMENT on post-process phase. TODO: support save all bases in checkpoint.
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 Columns []*table.Column AutoRandomColID int64 // convert auto id for shard rowid or auto random id base on row id generated by lightning AutoIDFn AutoIDConverterFn // 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) TableAllocators ¶
func (e *BaseKVEncoder) TableAllocators() autoid.Allocators
TableAllocators returns the allocators of the table
func (*BaseKVEncoder) TableMeta ¶
func (e *BaseKVEncoder) TableMeta() *model.TableInfo
TableMeta returns the meta of the table
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 GroupedPairs ¶
GroupedPairs is a map from index ID to KvPairs.
func (GroupedPairs) Clear ¶
func (GroupedPairs) Clear() encode.Rows
Clear implements the encode.Rows interface. It just satisfies the type system and should never be called.
func (GroupedPairs) SplitIntoChunks ¶
func (GroupedPairs) SplitIntoChunks(int) []encode.Rows
SplitIntoChunks implements the encode.Rows interface. It just satisfies the type system and should never be called.
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 {
// contains filtered or unexported fields
}
Session is used to provide context for lightning.
func GetSession4test ¶
GetSession4test is only used for test.
func NewSession ¶
NewSession creates a new Session.
func (*Session) GetColumnSize ¶
GetColumnSize returns the size of each column.
func (*Session) GetExprCtx ¶
func (s *Session) GetExprCtx() exprctx.ExprContext
GetExprCtx returns the expression context
func (*Session) GetTableCtx ¶
func (s *Session) GetTableCtx() tblctx.MutateContext
GetTableCtx returns the table MutateContext.
func (*Session) SetUserVarVal ¶
SetUserVarVal sets the value of a user variable.
func (*Session) TakeKvPairs ¶
TakeKvPairs returns the current Pairs and resets the buffer.
func (*Session) UnsetUserVar ¶
UnsetUserVar unsets a user variable.
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.