coprocessor

package
v0.0.0-...-8952261 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReadTimeoutMedium         = 60 * time.Second  // For requests that may need scan region.
	ReadTimeoutLong           = 150 * time.Second // For requests that may need scan region multiple times.
	GCTimeout                 = 5 * time.Minute
	UnsafeDestroyRangeTimeout = 5 * time.Minute
)

Timeout durations.

Variables

View Source
var MaxCallMsgSize = 1<<31 - 1

MaxCallMsgSize set max gRPC receive message size received from server. If any message size is larger than current value, an error will be reported from gRPC.

View Source
var MaxSendMsgSize = 1<<31 - 1

MaxSendMsgSize set max gRPC request message size sent to server. If any request message size is larger than current value, an error will be reported from gRPC.

Functions

func ColumnInfoToTypes

func ColumnInfoToTypes(columns []*model.ColumnInfo) []*types.FieldType

func EncodeRowValue

func EncodeRowValue(rawData []types.Datum, colIndex []int, timezone *time.Location) ([]byte, error)

func GenIndexKey

func GenIndexKey(sc *stmtctx.StatementContext, tableId int64, indexId int64, indexedValues []types.Datum, rowId int64, unique bool) ([]byte, error)

GenIndexKey generates storage key for index values. Returned distinct indicates whether the indexed values should be distinct in storage (i.e. whether handle is encoded in the key).

func GenRecordKey

func GenRecordKey(tableId, rowId int64) kv.Key

GenRecordKey implements table.Table interface.

func NewAggregationExecutor

func NewAggregationExecutor(agg []*tipb.Expr, groupBy []*tipb.Expr) *tipb.Executor

func NewBackOffer

func NewBackOffer(ctx context.Context) *tikv.Backoffer

func NewIndexScanExecutor

func NewIndexScanExecutor(tableInfo *MockTableInfo, indexId int64, desc bool) *tipb.Executor

func NewLimitExecutor

func NewLimitExecutor(limit uint64) *tipb.Executor

func NewSelectionScanExecutor

func NewSelectionScanExecutor(conditions []*tipb.Expr) *tipb.Executor

func NewTableScanExecutor

func NewTableScanExecutor(tableInfo *MockTableInfo, desc bool) *tipb.Executor

func NewTableScanExecutorWithTableInfo

func NewTableScanExecutorWithTableInfo(tableInfo *model.TableInfo, desc bool) *tipb.Executor

func NewTableScanExecutorWithTypes

func NewTableScanExecutorWithTypes(tableId int64, types []*types.FieldType, desc bool) *tipb.Executor

func NewTopNExecutor

func NewTopNExecutor(limit uint64, orderBy []*tipb.ByItem) *tipb.Executor

func TypesToColumnInfo

func TypesToColumnInfo(types []*types.FieldType) []*model.ColumnInfo

Types

type Client

type Client interface {
	// Close should release all data.
	Close() error
	// SendRequest sends Request.
	SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error)
}

Client is a client that sends RPC. It should not be used after calling Close().

type CopClient

type CopClient struct {
	PdClient    pd.Client
	RpcClient   *rpcClient
	RegionCache *tikv.RegionCache
	Storage     kv.Storage
	TikvClient  *txnkv.Client
}

CopClient is a client that sends RPC.

func NewClient

func NewClient(pdAddrs []string, security config.Security) (*CopClient, error)

NewRawKVClient creates a client with PD cluster addrs.

func (*CopClient) AddIndexRecord

func (c *CopClient) AddIndexRecord(tableId, indexId int64, rowId int64,
	indexColumnData []types.Datum, unique bool) error

func (*CopClient) AddIndexRecordWithTimezone

func (c *CopClient) AddIndexRecordWithTimezone(tableId, indexId int64, rowId int64,
	indexColumnData []types.Datum, unique bool, timezone *time.Location) error

insert a index record to tikv

func (*CopClient) AddTableRecord

func (c *CopClient) AddTableRecord(tableId int64, rowId int64, rowData []types.Datum) error

func (*CopClient) AddTableRecordWithColIndex

func (c *CopClient) AddTableRecordWithColIndex(tableId int64, rowId int64, rowData []types.Datum, colIndex []int) error

func (*CopClient) AddTableRecordWithTimezone

func (c *CopClient) AddTableRecordWithTimezone(tableId int64, rowId int64, rowData []types.Datum, colIndex []int, timezone *time.Location) error

insert a table record to tikv

func (*CopClient) Close

func (c *CopClient) Close()

func (*CopClient) GenAggExprPB

func (c *CopClient) GenAggExprPB(name string, args []expression.Expression, hasDistinct bool) (*tipb.Expr, error)

func (*CopClient) GetGroupByPB

func (c *CopClient) GetGroupByPB(expr expression.Expression) *tipb.Expr

func (*CopClient) GetIndexRegionIds

func (c *CopClient) GetIndexRegionIds(tableId, idxId int64) (regionIDs []uint64, err error)

func (*CopClient) GetRecordRegionIds

func (c *CopClient) GetRecordRegionIds(tableID int64) ([]uint64, error)

func (*CopClient) GetRegion

func (c *CopClient) GetRegion(id uint64) (*RegionMeta, error)

func (*CopClient) GetRegionInfo

func (c *CopClient) GetRegionInfo(ctx context.Context, id uint64) (*tikv.KeyLocation, error)

func (*CopClient) GetTableInfo

func (c *CopClient) GetTableInfo(dbName, tableName string) (*model.TableInfo, error)

func (*CopClient) GetTableRegion

func (c *CopClient) GetTableRegion(tableID int64) (*server.TableRegions, error)

func (*CopClient) ParseExprWithTableInfo

func (c *CopClient) ParseExprWithTableInfo(tableInfo *model.TableInfo, exprStr string) (*tipb.Expr, error)

func (*CopClient) ParseExpress

func (c *CopClient) ParseExpress(tableInfo *MockTableInfo, exprStr string) (*tipb.Expr, error)

func (*CopClient) Put

func (c *CopClient) Put(key, value []byte) error

Put stores a key-value pair to TiKV.

func (*CopClient) ScanIndexWithConditions

func (c *CopClient) ScanIndexWithConditions(ctx context.Context, tableInfo *MockTableInfo, indexId int64, conditions ...string) ([][]types.Datum, error)

func (*CopClient) ScanTableWithConditions

func (c *CopClient) ScanTableWithConditions(ctx context.Context, tableInfo *MockTableInfo, conditions ...string) ([][]types.Datum, error)

func (*CopClient) ScanTableWithConditionsAndTableInfo

func (c *CopClient) ScanTableWithConditionsAndTableInfo(ctx context.Context, tableInfo *model.TableInfo, conditions ...string) ([][]types.Datum, error)

func (*CopClient) ScanTableWithExpressionsAndTableInfo

func (c *CopClient) ScanTableWithExpressionsAndTableInfo(ctx context.Context, tableInfo *model.TableInfo, expList []*tipb.Expr) ([][]types.Datum, error)

func (*CopClient) Schema

func (c *CopClient) Schema() (infoschema.InfoSchema, error)

func (*CopClient) SendCoprocessorRequest

func (c *CopClient) SendCoprocessorRequest(ctx context.Context,
	tableId int64,
	returnTypes []*types.FieldType,
	executors []*tipb.Executor,
	getCopRange func() *copRanges,
	decodeTableRow func(chunk.Row, []*types.FieldType) error) error

send the coprocessor request to tikv

tableId: the id of the table returnTypes: column types that should be return by the coprocessor, set correct value base on the executors executors: the executors that send to tikv coprocessor getCopRange: a func that return range of the coprocessor request

 example:
 getCopRange := func() *copRanges {
		full := ranger.FullIntRange(false)
		keyRange, _ := distsql.IndexRangesToKVRanges(&stmtctx.StatementContext{InSelectStmt: true}, tableInfo.ID, indexId, full, nil)
		return &copRanges{mid: keyRange}
	}

decodeTableRow: a func that decode the row record

 example:
 	var values [][]types.Datum
	decodeTableRow := func(row chunk.Row, fs []*types.FieldType) error {
		var rowValue []types.Datum
		for idx, f := range fs {
			rowValue = append(rowValue, row.GetDatum(idx, f))
		}
		values = append(values, rowValue)
		return nil
	}

func (*CopClient) SendIndexScanRequest

func (c *CopClient) SendIndexScanRequest(ctx context.Context,
	tableInfo *MockTableInfo,
	indexId int64,
	returnTypes []*types.FieldType,
	executors []*tipb.Executor) ([][]types.Datum, error)

type MockTableInfo

type MockTableInfo struct {
	ID    int64
	Names []string
	Types []*types.FieldType
}

func InnerTableInfoToMockTableInfo

func InnerTableInfoToMockTableInfo(tableInfo *model.TableInfo) *MockTableInfo

func (*MockTableInfo) GetColumnInfo

func (tableInfo *MockTableInfo) GetColumnInfo() []*model.ColumnInfo

func (*MockTableInfo) ToInnerTableInfo

func (tableInfo *MockTableInfo) ToInnerTableInfo() *model.TableInfo

type RegionMeta

type RegionMeta struct {
	Region *metapb.Region
	Peer   *metapb.Peer
}

Jump to

Keyboard shortcuts

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