tables

package
v0.0.0-...-3903214 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultColumnFamily = "default"

	AttrKeyMode   = "mode"
	AttrKeyLayout = "layout"

	AttrFlexible = "flexible"
	AttrFixed    = "fixed"
	AttrCompact  = "compact"
	AttrSparse   = "sparse"
)

Variables

This section is empty.

Functions

func CastValue

func CastValue(ctx sessionctx.Context, val types.Datum, col *model.ColumnInfo, returnOverflow, forceIgnoreTruncate bool) (casted types.Datum, err error)

CastValue casts a value based on column type. If forceIgnoreTruncate is true, truncated errors will be ignored. If returnOverflow is true, don't handle overflow errors in this function. It's safe now and it's the same as the behavior of select statement. Set it to true only in FillVirtualColumnValue and UnionScanExec.Next() If the handle of err is changed latter, the behavior of forceIgnoreTruncate also need to change. TODO: change the third arg to TypeField. Not pass ColumnInfo.

func CheckOnce

func CheckOnce(cols []string) (map[string]struct{}, error)

func EvalColDefaultExpr

func EvalColDefaultExpr(ctx sessionctx.Context, col *model.ColumnInfo, defaultExpr ast.ExprNode) (types.Datum, error)

EvalColDefaultExpr eval default expr node to explicit default value.

func GetColDefaultValue

func GetColDefaultValue(ctx sessionctx.Context, col *model.ColumnInfo) (types.Datum, error)

GetColDefaultValue gets default value of the column.

func GetZeroValue

func GetZeroValue(col *model.ColumnInfo) types.Datum

GetZeroValue gets zero value for given column type.

func IsFlexible

func IsFlexible(cf *model.ColumnFamilyMeta) bool

func MakeTableFromMeta

func MakeTableFromMeta(tableMeta *model.TableMeta) table.Table

func NewResultIter

func NewResultIter(limit int64) *resultIter

func NewZettaIndex

func NewZettaIndex(physicalID int64, tblInfo *parser_model.TableInfo, indexInfo *parser_model.IndexInfo) table.Index

func TableFromMeta

func TableFromMeta(tableMeta *model.TableMeta, txn kv.Transaction) table.Table

Types

type Field

type Field struct {
	Family string
	Name   string
	Type   *tspb.Type
	Value  *tspb.Value
}

type IndexInfo

type IndexInfo struct {
	ID        int64
	IndexName string

	IndexPrefix kv.Key
	// contains filtered or unexported fields
}

func NewIndexInfo

func NewIndexInfo(meta *model.IndexMeta) *IndexInfo

func (*IndexInfo) BuildIndex

func (ii *IndexInfo) BuildIndex(tbMeta *model.TableMeta, recordKey, recordValue kv.Key) ([]byte, []byte, error)

BuildIndex build the index based on recordKey

func (*IndexInfo) FieldTypes

func (ii *IndexInfo) FieldTypes() []*types.FieldType

func (*IndexInfo) FromTableMeta

func (ii *IndexInfo) FromTableMeta(tbl *model.TableMeta, colIndex map[string]int)

func (*IndexInfo) Init

func (ii *IndexInfo) Init(tbMeta *model.TableMeta)

func (*IndexInfo) Keys

func (ii *IndexInfo) Keys() []*model.ColumnMeta

type KeyValue

type KeyValue struct {
	Key kv.Key
	Val []byte
}

type Table

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) AddRecord

func (t *Table) AddRecord(ctx sctx.Context, row []types.Datum) error

AddRecord only support write wide-row in default column family now.

func (*Table) BatchGet

func (t *Table) BatchGet(ctx sctx.Context, idxVals [][]types.Datum, cols []*table.Column,
	idxID int64, primary bool, fn table.RecordIterFunc) error

func (*Table) Cols

func (t *Table) Cols() []*table.Column

func (*Table) ColumnFamilies

func (t *Table) ColumnFamilies() []*model.ColumnFamilyMeta

func (*Table) Delete

func (t *Table) Delete(ctx context.Context, keySet *tspb.KeySet, family string, columns []string) error

func (*Table) FetchRecordsByIndex

func (t *Table) FetchRecordsByIndex(ctx sctx.Context, idxVals []types.Datum, cols []*table.Column,
	idxID int64, uniq bool, fn table.RecordIterFunc) error

FetchRecordsByIndex gets records by index. When uniq is true, we do a PointGet or BatchGet on tikv, based on number of keys. When uniq is false, we do a scan on tikv.

func (*Table) GetPhysicalID

func (t *Table) GetPhysicalID() int64

func (*Table) IndexPrefix

func (t *Table) IndexPrefix() kv.Key

func (*Table) IndexScan

func (t *Table) IndexScan(ctx sctx.Context, idxMeta *model.IndexMeta, lower, upper []byte,
	cols []*table.Column, fn table.RecordIterFunc, limit int64) error

func (t *tableCommon) IndexScan(ctx sctx.Context, idxVals []types.Datum, idxMeta *model.IndexMeta, reverse bool, cols []*table.Column, fn table.RecordIterFunc, limit int64) error {

func (*Table) Insert

func (t *Table) Insert(ctx context.Context, pkey *tspb.KeySet, family string, columns []string, values []*tspb.ListValue) error

func (*Table) InsertOrUpdate

func (t *Table) InsertOrUpdate(ctx context.Context, pkeyset *tspb.KeySet, family string, columns []string, values []*tspb.ListValue) error

func (*Table) IterRecords

func (t *Table) IterRecords(ctx sctx.Context, startKey, endKey kv.Key, cols []*table.Column, reverse bool, fn table.RecordIterFunc) error

Only support directly scan and primary key index scan.

func (*Table) Meta

func (t *Table) Meta() *model.TableMeta

func (*Table) ReadSparse

func (t *Table) ReadSparse(ctx context.Context, req *tspb.SparseReadRequest) (*resultIter, error)

func (*Table) ReadStore

func (t *Table) ReadStore(ctx context.Context, rr *tspb.ReadRequest) (*resultIter, error)

func (*Table) RecordPrefix

func (t *Table) RecordPrefix() kv.Key

func (*Table) RemoveRecord

func (t *Table) RemoveRecord(ctx sctx.Context, row []types.Datum) error

func (*Table) Replace

func (t *Table) Replace(ctx context.Context, pkey *tspb.KeySet, family string, columns []string, values []*tspb.ListValue) error

func (*Table) Scan

func (t *Table) Scan(ctx sctx.Context, idxVals []types.Datum, idxMeta *model.IndexMeta, isPrimay bool, lower, upper []byte,
	cols []*table.Column, fn table.RecordIterFunc, limit int64) error

Scan scan the table by index or primary. We do not provide a end bound here, use limit.

func (*Table) ScanStore

func (t *Table) ScanStore(ctx context.Context, scanReq *table.ScanRequest) (*resultIter, error)

func (*Table) SparseScan

func (t *Table) SparseScan(ctx context.Context, req *tspb.SparseScanRequest) (*resultIter, error)

func (*Table) Update

func (t *Table) Update(ctx context.Context, pkey *tspb.KeySet, family string, columns []string, values []*tspb.ListValue) error

func (*Table) UpdateRecord

func (t *Table) UpdateRecord(ctx sctx.Context, row []types.Datum, vals map[int64]types.Datum) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL