tables

package
v2.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanSkip

func CanSkip(info *model.TableInfo, col *table.Column, value types.Datum) bool

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

func CheckHandleExists(ctx sessionctx.Context, t table.Table, recordID int64) error

CheckHandleExists check whether recordID key exists. if not exists, return nil, otherwise return kv.ErrKeyExists error.

func DecodeHandle

func DecodeHandle(data []byte) (int64, error)

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 EncodeHandle

func EncodeHandle(h int64) []byte

EncodeHandle encodes handle in data.

func FindIndexByColName

func FindIndexByColName(t table.Table, name string) table.Index

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

func MemoryTableFromMeta(alloc autoid.Allocator, tblInfo *model.TableInfo) table.Table

MemoryTableFromMeta creates a Table instance from model.TableInfo.

func MockTableFromMeta

func MockTableFromMeta(tableInfo *model.TableInfo) table.Table

MockTableFromMeta only serves for test.

func NewIndex

func NewIndex(tableInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index

NewIndex builds a new Index object.

func TableFromMeta

func TableFromMeta(alloc autoid.Allocator, tblInfo *model.TableInfo) (table.Table, error)

TableFromMeta creates a Table instance from model.TableInfo.

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 *