Documentation ¶
Index ¶
- func CanSkip(info *model.TableInfo, col *table.Column, value types.Datum) bool
- func CheckHandleExists(ctx sessionctx.Context, t table.Table, recordID int64) error
- func DecodeHandle(data []byte) (int64, error)
- func DecodeRawRowData(ctx sessionctx.Context, meta *model.TableInfo, h int64, cols []*table.Column, ...) ([]types.Datum, map[int64]types.Datum, error)
- func EncodeHandle(h int64) []byte
- func FindIndexByColName(t table.Table, name string) table.Index
- func GetColDefaultValue(ctx sessionctx.Context, col *table.Column, defaultVals []types.Datum) (colVal types.Datum, err error)
- func MemoryTableFromMeta(alloc autoid.Allocator, tblInfo *model.TableInfo) table.Table
- func MockTableFromMeta(tableInfo *model.TableInfo) table.Table
- func NewIndex(tableInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index
- func TableFromMeta(alloc autoid.Allocator, tblInfo *model.TableInfo) (table.Table, error)
- type MemoryTable
- func (t *MemoryTable) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, ...) (recordID int64, err error)
- func (t *MemoryTable) AllocAutoID(ctx sessionctx.Context) (int64, error)
- func (t *MemoryTable) Allocator(ctx sessionctx.Context) autoid.Allocator
- func (t *MemoryTable) Cols() []*table.Column
- func (t *MemoryTable) DeletableIndices() []table.Index
- func (t *MemoryTable) FirstKey() kv.Key
- func (t *MemoryTable) IndexPrefix() kv.Key
- func (t *MemoryTable) Indices() []table.Index
- func (t *MemoryTable) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, ...) error
- func (t *MemoryTable) Meta() *model.TableInfo
- func (t *MemoryTable) RebaseAutoID(ctx sessionctx.Context, newBase int64, isSetStep bool) error
- func (t *MemoryTable) RecordKey(h int64) kv.Key
- func (t *MemoryTable) RecordPrefix() kv.Key
- func (t *MemoryTable) RemoveRecord(ctx sessionctx.Context, h int64, r []types.Datum) error
- func (t *MemoryTable) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error)
- func (t *MemoryTable) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
- func (t *MemoryTable) Seek(ctx sessionctx.Context, handle int64) (int64, bool, error)
- func (t *MemoryTable) Truncate()
- func (t *MemoryTable) Type() table.Type
- func (t *MemoryTable) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, ...) error
- func (t *MemoryTable) WritableCols() []*table.Column
- func (t *MemoryTable) WritableIndices() []table.Index
- type Table
- func (t *Table) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, ...) (recordID int64, err error)
- func (t *Table) AllocAutoID(ctx sessionctx.Context) (int64, error)
- func (t *Table) Allocator(ctx sessionctx.Context) autoid.Allocator
- func (t *Table) Cols() []*table.Column
- func (t *Table) DeletableIndices() []table.Index
- func (t *Table) FirstKey() kv.Key
- func (t *Table) IndexPrefix() kv.Key
- func (t *Table) Indices() []table.Index
- func (t *Table) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, ...) error
- func (t *Table) Meta() *model.TableInfo
- func (t *Table) RebaseAutoID(ctx sessionctx.Context, newBase int64, isSetStep bool) error
- func (t *Table) RecordKey(h int64) kv.Key
- func (t *Table) RecordPrefix() kv.Key
- func (t *Table) RemoveRecord(ctx sessionctx.Context, h int64, r []types.Datum) error
- func (t *Table) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error)
- func (t *Table) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
- func (t *Table) Seek(ctx sessionctx.Context, h int64) (int64, bool, error)
- func (t *Table) Type() table.Type
- func (t *Table) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, ...) error
- func (t *Table) WritableCols() []*table.Column
- func (t *Table) WritableIndices() []table.Index
- type VirtualDataSource
- type VirtualTable
- func (vt *VirtualTable) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, ...) (recordID int64, err error)
- func (vt *VirtualTable) AllocAutoID(ctx sessionctx.Context) (int64, error)
- func (vt *VirtualTable) Allocator(ctx sessionctx.Context) autoid.Allocator
- func (vt *VirtualTable) Cols() []*table.Column
- func (vt *VirtualTable) DeletableIndices() []table.Index
- func (vt *VirtualTable) FirstKey() kv.Key
- func (vt *VirtualTable) IndexPrefix() kv.Key
- func (vt *VirtualTable) Indices() []table.Index
- func (vt *VirtualTable) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, ...) error
- func (vt *VirtualTable) Meta() *model.TableInfo
- func (vt *VirtualTable) RebaseAutoID(ctx sessionctx.Context, newBase int64, isSetStep bool) error
- func (vt *VirtualTable) RecordKey(h int64) kv.Key
- func (vt *VirtualTable) RecordPrefix() kv.Key
- func (vt *VirtualTable) RemoveRecord(ctx sessionctx.Context, h int64, r []types.Datum) error
- func (vt *VirtualTable) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error)
- func (vt *VirtualTable) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
- func (vt *VirtualTable) Seek(ctx sessionctx.Context, h int64) (int64, bool, error)
- func (vt *VirtualTable) Type() table.Type
- func (vt *VirtualTable) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, ...) error
- func (vt *VirtualTable) WritableCols() []*table.Column
- func (vt *VirtualTable) WritableIndices() []table.Index
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanSkip ¶
CanSkip is for these cases, we can skip the columns in encoded row: 1. the column is included in primary key; 2. the column's default value is null, and the value equals to that; 3. the column is virtual generated.
func CheckHandleExists ¶
CheckHandleExists check whether recordID key exists. if not exists, return nil, otherwise return kv.ErrKeyExists error.
func DecodeHandle ¶
DecodeHandle decodes handle in data.
func DecodeRawRowData ¶
func DecodeRawRowData(ctx sessionctx.Context, meta *model.TableInfo, h int64, cols []*table.Column, value []byte) ([]types.Datum, map[int64]types.Datum, error)
DecodeRawRowData decodes raw row data into a datum slice and a (columnID:columnValue) map.
func FindIndexByColName ¶
FindIndexByColName implements table.Table FindIndexByColName interface.
func GetColDefaultValue ¶
func GetColDefaultValue(ctx sessionctx.Context, col *table.Column, defaultVals []types.Datum) ( colVal types.Datum, err error)
GetColDefaultValue gets a column default value. The defaultVals is used to avoid calculating the default value multiple times.
func MemoryTableFromMeta ¶
MemoryTableFromMeta creates a Table instance from model.TableInfo.
func MockTableFromMeta ¶
MockTableFromMeta only serves for test.
func NewIndex ¶
NewIndex builds a new Index object.
Types ¶
type MemoryTable ¶
type MemoryTable struct { ID int64 Name model.CIStr Columns []*table.Column // contains filtered or unexported fields }
MemoryTable implements table.Table interface.
func (*MemoryTable) AddRecord ¶
func (t *MemoryTable) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, isUpdate ...bool) (recordID int64, err error)
AddRecord implements table.Table AddRecord interface.
func (*MemoryTable) AllocAutoID ¶
func (t *MemoryTable) AllocAutoID(ctx sessionctx.Context) (int64, error)
AllocAutoID implements table.Table AllocAutoID interface.
func (*MemoryTable) Allocator ¶
func (t *MemoryTable) Allocator(ctx sessionctx.Context) autoid.Allocator
Allocator implements table.Table Allocator interface.
func (*MemoryTable) Cols ¶
func (t *MemoryTable) Cols() []*table.Column
Cols implements table.Table Cols interface.
func (*MemoryTable) DeletableIndices ¶
func (t *MemoryTable) DeletableIndices() []table.Index
DeletableIndices implements table.Table DeletableIndices interface.
func (*MemoryTable) FirstKey ¶
func (t *MemoryTable) FirstKey() kv.Key
FirstKey implements table.Table FirstKey interface.
func (*MemoryTable) IndexPrefix ¶
func (t *MemoryTable) IndexPrefix() kv.Key
IndexPrefix implements table.Table IndexPrefix interface.
func (*MemoryTable) Indices ¶
func (t *MemoryTable) Indices() []table.Index
Indices implements table.Table Indices interface.
func (*MemoryTable) IterRecords ¶
func (t *MemoryTable) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, fn table.RecordIterFunc) error
IterRecords implements table.Table IterRecords interface.
func (*MemoryTable) Meta ¶
func (t *MemoryTable) Meta() *model.TableInfo
Meta implements table.Table Meta interface.
func (*MemoryTable) RebaseAutoID ¶
func (t *MemoryTable) RebaseAutoID(ctx sessionctx.Context, newBase int64, isSetStep bool) error
RebaseAutoID implements table.Table RebaseAutoID interface.
func (*MemoryTable) RecordKey ¶
func (t *MemoryTable) RecordKey(h int64) kv.Key
RecordKey implements table.Table RecordKey interface.
func (*MemoryTable) RecordPrefix ¶
func (t *MemoryTable) RecordPrefix() kv.Key
RecordPrefix implements table.Table RecordPrefix interface.
func (*MemoryTable) RemoveRecord ¶
func (t *MemoryTable) RemoveRecord(ctx sessionctx.Context, h int64, r []types.Datum) error
RemoveRecord implements table.Table RemoveRecord interface.
func (*MemoryTable) Row ¶
func (t *MemoryTable) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error)
Row implements table.Table Row interface.
func (*MemoryTable) RowWithCols ¶
func (t *MemoryTable) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
RowWithCols implements table.Table RowWithCols interface.
func (*MemoryTable) Seek ¶
func (t *MemoryTable) Seek(ctx sessionctx.Context, handle int64) (int64, bool, error)
Seek seeks the handle
func (*MemoryTable) Truncate ¶
func (t *MemoryTable) Truncate()
Truncate drops all data in Memory Table.
func (*MemoryTable) Type ¶
func (t *MemoryTable) Type() table.Type
Type implements table.Table Type interface.
func (*MemoryTable) UpdateRecord ¶
func (t *MemoryTable) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, touched []bool) error
UpdateRecord implements table.Table UpdateRecord interface.
func (*MemoryTable) WritableCols ¶
func (t *MemoryTable) WritableCols() []*table.Column
WritableCols implements table.Table WritableCols interface.
func (*MemoryTable) WritableIndices ¶
func (t *MemoryTable) WritableIndices() []table.Index
WritableIndices implements table.Table WritableIndices interface.
type Table ¶
type Table struct { ID int64 Name model.CIStr Columns []*table.Column // contains filtered or unexported fields }
Table implements table.Table interface.
func (*Table) AddRecord ¶
func (t *Table) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, isUpdates ...bool) (recordID int64, err error)
AddRecord implements table.Table AddRecord interface.
func (*Table) AllocAutoID ¶
func (t *Table) AllocAutoID(ctx sessionctx.Context) (int64, error)
AllocAutoID implements table.Table AllocAutoID interface.
func (*Table) Allocator ¶
func (t *Table) Allocator(ctx sessionctx.Context) autoid.Allocator
Allocator implements table.Table Allocator interface.
func (*Table) Cols ¶
Cols implements table.Table Cols interface.
func (*Table) DeletableIndices ¶
DeletableIndices implements table.Table DeletableIndices interface.
func (*Table) FirstKey ¶
FirstKey implements table.Table FirstKey interface.
func (*Table) IndexPrefix ¶
IndexPrefix implements table.Table IndexPrefix interface.
func (*Table) Indices ¶
Indices implements table.Table Indices interface.
func (*Table) IterRecords ¶
func (t *Table) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, fn table.RecordIterFunc) error
IterRecords implements table.Table IterRecords interface.
func (*Table) Meta ¶
Meta implements table.Table Meta interface.
func (*Table) RebaseAutoID ¶
RebaseAutoID implements table.Table RebaseAutoID interface.
func (*Table) RecordKey ¶
RecordKey implements table.Table RecordKey interface.
func (*Table) RecordPrefix ¶
RecordPrefix implements table.Table RecordPrefix interface.
func (*Table) RemoveRecord ¶
RemoveRecord implements table.Table RemoveRecord interface.
func (*Table) Row ¶
Row implements table.Table Row interface.
func (*Table) RowWithCols ¶
func (t *Table) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
RowWithCols implements table.Table RowWithCols interface.
func (*Table) Seek ¶
Seek implements table.Table Seek interface.
func (*Table) UpdateRecord ¶
func (t *Table) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, touched []bool) error
UpdateRecord implements table.Table UpdateRecord interface. `touched` means which columns are really modified, used for secondary indices. Length of `oldData` and `newData` equals to length of `t.WritableCols()`.
func (*Table) WritableCols ¶
WritableCols implements table WritableCols interface.
type VirtualDataSource ¶
type VirtualDataSource interface { // GetRows do the actual job GetRows(ctx sessionctx.Context) (fullRows [][]types.Datum, err error) // Meta return the meta of table Meta() *model.TableInfo // Cols return the cols of table Cols() []*table.Column }
VirtualDataSource is used to extract data from the struct in memory.
type VirtualTable ¶
type VirtualTable struct {
// contains filtered or unexported fields
}
VirtualTable stands for the fake table all its data is in the memory. dataSource: the function to get rows @TODO this table is almost the same as the infoschema tables, but we need to use it in performance schema. @TODO So we have to move it here, sometimes we need to refactor the infoschema tables to decrease the multiplicity of the codes
func CreateVirtualTable ¶
func CreateVirtualTable(dataSource VirtualDataSource) *VirtualTable
CreateVirtualTable as its name
func (*VirtualTable) AddRecord ¶
func (vt *VirtualTable) AddRecord(ctx sessionctx.Context, r []types.Datum, skipHandleCheck bool, isUpdate ...bool) (recordID int64, err error)
AddRecord implements table.Table Type interface.
func (*VirtualTable) AllocAutoID ¶
func (vt *VirtualTable) AllocAutoID(ctx sessionctx.Context) (int64, error)
AllocAutoID implements table.Table Type interface.
func (*VirtualTable) Allocator ¶
func (vt *VirtualTable) Allocator(ctx sessionctx.Context) autoid.Allocator
Allocator implements table.Table Type interface.
func (*VirtualTable) Cols ¶
func (vt *VirtualTable) Cols() []*table.Column
Cols implements table.Table Type interface.
func (*VirtualTable) DeletableIndices ¶
func (vt *VirtualTable) DeletableIndices() []table.Index
DeletableIndices implements table.Table Type interface.
func (*VirtualTable) FirstKey ¶
func (vt *VirtualTable) FirstKey() kv.Key
FirstKey implements table.Table Type interface.
func (*VirtualTable) IndexPrefix ¶
func (vt *VirtualTable) IndexPrefix() kv.Key
IndexPrefix implements table.Table Type interface.
func (*VirtualTable) Indices ¶
func (vt *VirtualTable) Indices() []table.Index
Indices implements table.Table Type interface.
func (*VirtualTable) IterRecords ¶
func (vt *VirtualTable) IterRecords(ctx sessionctx.Context, startKey kv.Key, cols []*table.Column, fn table.RecordIterFunc) error
IterRecords implements table.Table Type interface.
func (*VirtualTable) Meta ¶
func (vt *VirtualTable) Meta() *model.TableInfo
Meta implements table.Table Type interface.
func (*VirtualTable) RebaseAutoID ¶
func (vt *VirtualTable) RebaseAutoID(ctx sessionctx.Context, newBase int64, isSetStep bool) error
RebaseAutoID implements table.Table Type interface.
func (*VirtualTable) RecordKey ¶
func (vt *VirtualTable) RecordKey(h int64) kv.Key
RecordKey implements table.Table Type interface.
func (*VirtualTable) RecordPrefix ¶
func (vt *VirtualTable) RecordPrefix() kv.Key
RecordPrefix implements table.Table Type interface.
func (*VirtualTable) RemoveRecord ¶
func (vt *VirtualTable) RemoveRecord(ctx sessionctx.Context, h int64, r []types.Datum) error
RemoveRecord implements table.Table Type interface.
func (*VirtualTable) Row ¶
func (vt *VirtualTable) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error)
Row implements table.Table Type interface.
func (*VirtualTable) RowWithCols ¶
func (vt *VirtualTable) RowWithCols(ctx sessionctx.Context, h int64, cols []*table.Column) ([]types.Datum, error)
RowWithCols implements table.Table Type interface.
func (*VirtualTable) Seek ¶
func (vt *VirtualTable) Seek(ctx sessionctx.Context, h int64) (int64, bool, error)
Seek implements table.Table Type interface.
func (*VirtualTable) Type ¶
func (vt *VirtualTable) Type() table.Type
Type implements table.Table Type interface.
func (*VirtualTable) UpdateRecord ¶
func (vt *VirtualTable) UpdateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datum, touched []bool) error
UpdateRecord implements table.Table Type interface.
func (*VirtualTable) WritableCols ¶
func (vt *VirtualTable) WritableCols() []*table.Column
WritableCols implements table.Table Type interface.
func (*VirtualTable) WritableIndices ¶
func (vt *VirtualTable) WritableIndices() []table.Index
WritableIndices implements table.Table Type interface.