Documentation ¶
Index ¶
- Constants
- Variables
- func ColumnInfoToTypes(columns []*model.ColumnInfo) []*types.FieldType
- func EncodeRowValue(rawData []types.Datum, colIndex []int, timezone *time.Location) ([]byte, error)
- func GenIndexKey(sc *stmtctx.StatementContext, tableId int64, indexId int64, ...) ([]byte, error)
- func GenRecordKey(tableId, rowId int64) kv.Key
- func NewAggregationExecutor(agg []*tipb.Expr, groupBy []*tipb.Expr) *tipb.Executor
- func NewBackOffer(ctx context.Context) *tikv.Backoffer
- func NewIndexScanExecutor(tableInfo *MockTableInfo, indexId int64, desc bool) *tipb.Executor
- func NewLimitExecutor(limit uint64) *tipb.Executor
- func NewSelectionScanExecutor(conditions []*tipb.Expr) *tipb.Executor
- func NewTableScanExecutor(tableInfo *MockTableInfo, desc bool) *tipb.Executor
- func NewTableScanExecutorWithTableInfo(tableInfo *model.TableInfo, desc bool) *tipb.Executor
- func NewTableScanExecutorWithTypes(tableId int64, types []*types.FieldType, desc bool) *tipb.Executor
- func NewTopNExecutor(limit uint64, orderBy []*tipb.ByItem) *tipb.Executor
- func TypesToColumnInfo(types []*types.FieldType) []*model.ColumnInfo
- type Client
- type CopClient
- func (c *CopClient) AddIndexRecord(tableId, indexId int64, rowId int64, indexColumnData []types.Datum, ...) error
- func (c *CopClient) AddIndexRecordWithTimezone(tableId, indexId int64, rowId int64, indexColumnData []types.Datum, ...) error
- func (c *CopClient) AddTableRecord(tableId int64, rowId int64, rowData []types.Datum) error
- func (c *CopClient) AddTableRecordWithColIndex(tableId int64, rowId int64, rowData []types.Datum, colIndex []int) error
- func (c *CopClient) AddTableRecordWithTimezone(tableId int64, rowId int64, rowData []types.Datum, colIndex []int, ...) error
- func (c *CopClient) Close()
- func (c *CopClient) GenAggExprPB(name string, args []expression.Expression, hasDistinct bool) (*tipb.Expr, error)
- func (c *CopClient) GetGroupByPB(expr expression.Expression) *tipb.Expr
- func (c *CopClient) GetIndexRegionIds(tableId, idxId int64) (regionIDs []uint64, err error)
- func (c *CopClient) GetRecordRegionIds(tableID int64) ([]uint64, error)
- func (c *CopClient) GetRegion(id uint64) (*RegionMeta, error)
- func (c *CopClient) GetRegionInfo(ctx context.Context, id uint64) (*tikv.KeyLocation, error)
- func (c *CopClient) GetTableInfo(dbName, tableName string) (*model.TableInfo, error)
- func (c *CopClient) GetTableRegion(tableID int64) (*server.TableRegions, error)
- func (c *CopClient) ParseExprWithTableInfo(tableInfo *model.TableInfo, exprStr string) (*tipb.Expr, error)
- func (c *CopClient) ParseExpress(tableInfo *MockTableInfo, exprStr string) (*tipb.Expr, error)
- func (c *CopClient) Put(key, value []byte) error
- func (c *CopClient) ScanIndexWithConditions(ctx context.Context, tableInfo *MockTableInfo, indexId int64, ...) ([][]types.Datum, error)
- func (c *CopClient) ScanTableWithConditions(ctx context.Context, tableInfo *MockTableInfo, conditions ...string) ([][]types.Datum, error)
- func (c *CopClient) ScanTableWithConditionsAndTableInfo(ctx context.Context, tableInfo *model.TableInfo, conditions ...string) ([][]types.Datum, error)
- func (c *CopClient) ScanTableWithExpressionsAndTableInfo(ctx context.Context, tableInfo *model.TableInfo, expList []*tipb.Expr) ([][]types.Datum, error)
- func (c *CopClient) Schema() (infoschema.InfoSchema, error)
- func (c *CopClient) SendCoprocessorRequest(ctx context.Context, tableId int64, returnTypes []*types.FieldType, ...) error
- func (c *CopClient) SendIndexScanRequest(ctx context.Context, tableInfo *MockTableInfo, indexId int64, ...) ([][]types.Datum, error)
- type MockTableInfo
- type RegionMeta
Constants ¶
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 ¶
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.
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 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 ¶
GenRecordKey implements table.Table interface.
func NewAggregationExecutor ¶
func NewAggregationExecutor(agg []*tipb.Expr, groupBy []*tipb.Expr) *tipb.Executor
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 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 (*CopClient) AddIndexRecord ¶
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 (*CopClient) AddTableRecordWithColIndex ¶
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) 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 (*CopClient) GetRecordRegionIds ¶
func (*CopClient) GetRegionInfo ¶
func (*CopClient) GetTableInfo ¶
func (*CopClient) GetTableRegion ¶
func (c *CopClient) GetTableRegion(tableID int64) (*server.TableRegions, error)
func (*CopClient) ParseExprWithTableInfo ¶
func (*CopClient) ParseExpress ¶
func (c *CopClient) ParseExpress(tableInfo *MockTableInfo, exprStr string) (*tipb.Expr, error)
func (*CopClient) ScanIndexWithConditions ¶
func (*CopClient) ScanTableWithConditions ¶
func (*CopClient) ScanTableWithConditionsAndTableInfo ¶
func (*CopClient) ScanTableWithExpressionsAndTableInfo ¶
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 }
type MockTableInfo ¶
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