Documentation ¶
Index ¶
- func CommonHandleRangesToKVRanges(sc *stmtctx.StatementContext, tids []int64, ranges []*ranger.Range) (*kv.KeyRanges, error)
- func EncodeIndexKey(sc *stmtctx.StatementContext, ran *ranger.Range) ([]byte, []byte, error)
- func GetSystemEndian() tipb.Endian
- func IndexRangesToKVRanges(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range, ...) (*kv.KeyRanges, error)
- func IndexRangesToKVRangesForTables(sc *stmtctx.StatementContext, tids []int64, idxID int64, ...) (*kv.KeyRanges, error)
- func IndexRangesToKVRangesWithInterruptSignal(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range, ...) (*kv.KeyRanges, error)
- func PartitionHandlesToKVRanges(handles []kv.Handle) []kv.KeyRange
- func SetEncodeType(ctx sessionctx.Context, dagReq *tipb.DAGRequest)
- func SetTiFlashMaxThreadsInContext(ctx context.Context, sctx sessionctx.Context) context.Context
- func SplitRangesAcrossInt64Boundary(ranges []*ranger.Range, keepOrder bool, desc bool, isCommonHandle bool) ([]*ranger.Range, []*ranger.Range)
- func TableHandleRangesToKVRanges(sc *stmtctx.StatementContext, tid []int64, isCommonHandle bool, ...) (*kv.KeyRanges, error)
- func TableHandlesToKVRanges(tid int64, handles []kv.Handle) ([]kv.KeyRange, []int)
- func TableRangesToKVRanges(tid int64, ranges []*ranger.Range, fb *statistics.QueryFeedback) []kv.KeyRange
- func VerifyTxnScope(txnScope string, physicalTableID int64, is infoschema.InfoSchema) bool
- func WithSQLKvExecCounterInterceptor(ctx context.Context, stmtCtx *stmtctx.StatementContext) context.Context
- type CopRuntimeStats
- type RequestBuilder
- func (builder *RequestBuilder) Build() (*kv.Request, error)
- func (builder *RequestBuilder) SetAllowBatchCop(batchCop bool) *RequestBuilder
- func (builder *RequestBuilder) SetAnalyzeRequest(ana *tipb.AnalyzeReq, isoLevel kv.IsoLevel) *RequestBuilder
- func (builder *RequestBuilder) SetChecksumRequest(checksum *tipb.ChecksumRequest) *RequestBuilder
- func (builder *RequestBuilder) SetClosestReplicaReadAdjuster(chkFn kv.CoprRequestAdjuster) *RequestBuilder
- func (builder *RequestBuilder) SetConcurrency(concurrency int) *RequestBuilder
- func (builder *RequestBuilder) SetDAGRequest(dag *tipb.DAGRequest) *RequestBuilder
- func (builder *RequestBuilder) SetDesc(desc bool) *RequestBuilder
- func (builder *RequestBuilder) SetFromInfoSchema(pis interface{}) *RequestBuilder
- func (builder *RequestBuilder) SetFromSessionVars(sv *variable.SessionVars) *RequestBuilder
- func (builder *RequestBuilder) SetHandleRanges(sc *stmtctx.StatementContext, tid int64, isCommonHandle bool, ...) *RequestBuilder
- func (builder *RequestBuilder) SetHandleRangesForTables(sc *stmtctx.StatementContext, tid []int64, isCommonHandle bool, ...) *RequestBuilder
- func (builder *RequestBuilder) SetIndexRanges(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range) *RequestBuilder
- func (builder *RequestBuilder) SetIndexRangesForTables(sc *stmtctx.StatementContext, tids []int64, idxID int64, ...) *RequestBuilder
- func (builder *RequestBuilder) SetIsStaleness(is bool) *RequestBuilder
- func (builder *RequestBuilder) SetKeepOrder(order bool) *RequestBuilder
- func (builder *RequestBuilder) SetKeyRanges(keyRanges []kv.KeyRange) *RequestBuilder
- func (builder *RequestBuilder) SetMemTracker(tracker *memory.Tracker) *RequestBuilder
- func (builder *RequestBuilder) SetPaging(paging bool) *RequestBuilder
- func (builder *RequestBuilder) SetPartitionIDAndRanges(partitionIDAndRanges []kv.PartitionIDAndRanges) *RequestBuilder
- func (builder *RequestBuilder) SetPartitionKeyRanges(keyRanges [][]kv.KeyRange) *RequestBuilder
- func (builder *RequestBuilder) SetPartitionsAndHandles(handles []kv.Handle) *RequestBuilder
- func (builder *RequestBuilder) SetReadReplicaScope(scope string) *RequestBuilder
- func (builder *RequestBuilder) SetResourceGroupTagger(tagger tikvrpc.ResourceGroupTagger) *RequestBuilder
- func (builder *RequestBuilder) SetStartTS(startTS uint64) *RequestBuilder
- func (builder *RequestBuilder) SetStoreType(storeType kv.StoreType) *RequestBuilder
- func (builder *RequestBuilder) SetTableHandles(tid int64, handles []kv.Handle) *RequestBuilder
- func (builder *RequestBuilder) SetTableRanges(tid int64, tableRanges []*ranger.Range, fb *statistics.QueryFeedback) *RequestBuilder
- func (builder *RequestBuilder) SetTiDBServerID(serverID uint64) *RequestBuilder
- func (builder *RequestBuilder) SetTxnScope(scope string) *RequestBuilder
- func (builder *RequestBuilder) SetWrappedKeyRanges(keyRanges *kv.KeyRanges) *RequestBuilder
- type SelectResult
- func Analyze(ctx context.Context, client kv.Client, kvReq *kv.Request, vars interface{}, ...) (SelectResult, error)
- func Checksum(ctx context.Context, client kv.Client, kvReq *kv.Request, vars interface{}) (SelectResult, error)
- func DispatchMPPTasks(ctx context.Context, sctx sessionctx.Context, tasks []*kv.MPPDispatchRequest, ...) (SelectResult, error)
- func NewSerialSelectResults(selectResults []SelectResult) SelectResult
- func Select(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, ...) (SelectResult, error)
- func SelectWithRuntimeStats(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, ...) (SelectResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommonHandleRangesToKVRanges ¶
func CommonHandleRangesToKVRanges(sc *stmtctx.StatementContext, tids []int64, ranges []*ranger.Range) (*kv.KeyRanges, error)
CommonHandleRangesToKVRanges converts common handle ranges to "KeyRange".
func EncodeIndexKey ¶
EncodeIndexKey gets encoded keys containing low and high
func IndexRangesToKVRanges ¶
func IndexRangesToKVRanges(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range, fb *statistics.QueryFeedback) (*kv.KeyRanges, error)
IndexRangesToKVRanges converts index ranges to "KeyRange".
func IndexRangesToKVRangesForTables ¶
func IndexRangesToKVRangesForTables(sc *stmtctx.StatementContext, tids []int64, idxID int64, ranges []*ranger.Range, fb *statistics.QueryFeedback) (*kv.KeyRanges, error)
IndexRangesToKVRangesForTables converts indexes ranges to "KeyRange".
func IndexRangesToKVRangesWithInterruptSignal ¶
func IndexRangesToKVRangesWithInterruptSignal(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range, fb *statistics.QueryFeedback, memTracker *memory.Tracker, interruptSignal *atomic.Value) (*kv.KeyRanges, error)
IndexRangesToKVRangesWithInterruptSignal converts index ranges to "KeyRange". The process can be interrupted by set `interruptSignal` to true.
func PartitionHandlesToKVRanges ¶
PartitionHandlesToKVRanges convert ParitionHandles to kv ranges. Handle in slices must be kv.PartitionHandle
func SetEncodeType ¶
func SetEncodeType(ctx sessionctx.Context, dagReq *tipb.DAGRequest)
SetEncodeType sets the encoding method for the DAGRequest. The supported encoding methods are: 1. TypeChunk: the result is encoded using the Chunk format, refer util/chunk/chunk.go 2. TypeDefault: the result is encoded row by row
func SetTiFlashMaxThreadsInContext ¶
SetTiFlashMaxThreadsInContext set the config TiFlash max threads in context.
func SplitRangesAcrossInt64Boundary ¶
func SplitRangesAcrossInt64Boundary(ranges []*ranger.Range, keepOrder bool, desc bool, isCommonHandle bool) ([]*ranger.Range, []*ranger.Range)
SplitRangesAcrossInt64Boundary split the ranges into two groups: 1. signedRanges is less or equal than MaxInt64 2. unsignedRanges is greater than MaxInt64
We do this because every key of tikv is encoded as an int64. As a result, MaxUInt64 is small than zero when interpreted as an int64 variable.
This function does the following:
- split ranges into two groups as described above.
- if there's a range that straddles the int64 boundary, split it into two ranges, which results in one smaller and one greater than MaxInt64.
if `KeepOrder` is false, we merge the two groups of ranges into one group, to save an rpc call later if `desc` is false, return signed ranges first, vice versa.
func TableHandleRangesToKVRanges ¶
func TableHandleRangesToKVRanges(sc *stmtctx.StatementContext, tid []int64, isCommonHandle bool, ranges []*ranger.Range, fb *statistics.QueryFeedback) (*kv.KeyRanges, error)
TableHandleRangesToKVRanges convert table handle ranges to "KeyRanges" for multiple tables.
func TableHandlesToKVRanges ¶
TableHandlesToKVRanges converts sorted handle to kv ranges. For continuous handles, we should merge them to a single key range.
func TableRangesToKVRanges ¶
func TableRangesToKVRanges(tid int64, ranges []*ranger.Range, fb *statistics.QueryFeedback) []kv.KeyRange
TableRangesToKVRanges converts table ranges to "KeyRange". Note this function should not be exported, but currently br refers to it, so have to keep it.
func VerifyTxnScope ¶
func VerifyTxnScope(txnScope string, physicalTableID int64, is infoschema.InfoSchema) bool
VerifyTxnScope verify whether the txnScope and visited physical table break the leader rule's dcLocation.
func WithSQLKvExecCounterInterceptor ¶
func WithSQLKvExecCounterInterceptor(ctx context.Context, stmtCtx *stmtctx.StatementContext) context.Context
WithSQLKvExecCounterInterceptor binds an interceptor for client-go to count the number of SQL executions of each TiKV (if any).
Types ¶
type CopRuntimeStats ¶
type CopRuntimeStats interface { // GetCopRuntimeStats gets the cop runtime stats information. GetCopRuntimeStats() *copr.CopRuntimeStats }
CopRuntimeStats is a interface uses to check whether the result has cop runtime stats.
type RequestBuilder ¶
RequestBuilder is used to build a "kv.Request". It is called before we issue a kv request by "Select".
func (*RequestBuilder) Build ¶
func (builder *RequestBuilder) Build() (*kv.Request, error)
Build builds a "kv.Request".
func (*RequestBuilder) SetAllowBatchCop ¶
func (builder *RequestBuilder) SetAllowBatchCop(batchCop bool) *RequestBuilder
SetAllowBatchCop sets `BatchCop` property.
func (*RequestBuilder) SetAnalyzeRequest ¶
func (builder *RequestBuilder) SetAnalyzeRequest(ana *tipb.AnalyzeReq, isoLevel kv.IsoLevel) *RequestBuilder
SetAnalyzeRequest sets the request type to "ReqTypeAnalyze" and construct request data.
func (*RequestBuilder) SetChecksumRequest ¶
func (builder *RequestBuilder) SetChecksumRequest(checksum *tipb.ChecksumRequest) *RequestBuilder
SetChecksumRequest sets the request type to "ReqTypeChecksum" and construct request data.
func (*RequestBuilder) SetClosestReplicaReadAdjuster ¶
func (builder *RequestBuilder) SetClosestReplicaReadAdjuster(chkFn kv.CoprRequestAdjuster) *RequestBuilder
SetClosestReplicaReadAdjuster sets request CoprRequestAdjuster
func (*RequestBuilder) SetConcurrency ¶
func (builder *RequestBuilder) SetConcurrency(concurrency int) *RequestBuilder
SetConcurrency sets "Concurrency" for "kv.Request".
func (*RequestBuilder) SetDAGRequest ¶
func (builder *RequestBuilder) SetDAGRequest(dag *tipb.DAGRequest) *RequestBuilder
SetDAGRequest sets the request type to "ReqTypeDAG" and construct request data.
func (*RequestBuilder) SetDesc ¶
func (builder *RequestBuilder) SetDesc(desc bool) *RequestBuilder
SetDesc sets "Desc" for "kv.Request".
func (*RequestBuilder) SetFromInfoSchema ¶
func (builder *RequestBuilder) SetFromInfoSchema(pis interface{}) *RequestBuilder
SetFromInfoSchema sets the following fields from infoSchema: "bundles"
func (*RequestBuilder) SetFromSessionVars ¶
func (builder *RequestBuilder) SetFromSessionVars(sv *variable.SessionVars) *RequestBuilder
SetFromSessionVars sets the following fields for "kv.Request" from session variables: "Concurrency", "IsolationLevel", "NotFillCache", "TaskID", "Priority", "ReplicaRead", "ResourceGroupTagger".
func (*RequestBuilder) SetHandleRanges ¶
func (builder *RequestBuilder) SetHandleRanges(sc *stmtctx.StatementContext, tid int64, isCommonHandle bool, ranges []*ranger.Range, fb *statistics.QueryFeedback) *RequestBuilder
SetHandleRanges sets "KeyRanges" for "kv.Request" by converting table handle range "ranges" to "KeyRanges" firstly.
func (*RequestBuilder) SetHandleRangesForTables ¶
func (builder *RequestBuilder) SetHandleRangesForTables(sc *stmtctx.StatementContext, tid []int64, isCommonHandle bool, ranges []*ranger.Range, fb *statistics.QueryFeedback) *RequestBuilder
SetHandleRangesForTables sets "KeyRanges" for "kv.Request" by converting table handle range "ranges" to "KeyRanges" firstly for multiple tables.
func (*RequestBuilder) SetIndexRanges ¶
func (builder *RequestBuilder) SetIndexRanges(sc *stmtctx.StatementContext, tid, idxID int64, ranges []*ranger.Range) *RequestBuilder
SetIndexRanges sets "KeyRanges" for "kv.Request" by converting index range "ranges" to "KeyRanges" firstly.
func (*RequestBuilder) SetIndexRangesForTables ¶
func (builder *RequestBuilder) SetIndexRangesForTables(sc *stmtctx.StatementContext, tids []int64, idxID int64, ranges []*ranger.Range) *RequestBuilder
SetIndexRangesForTables sets "KeyRanges" for "kv.Request" by converting multiple indexes range "ranges" to "KeyRanges" firstly.
func (*RequestBuilder) SetIsStaleness ¶
func (builder *RequestBuilder) SetIsStaleness(is bool) *RequestBuilder
SetIsStaleness sets request IsStaleness
func (*RequestBuilder) SetKeepOrder ¶
func (builder *RequestBuilder) SetKeepOrder(order bool) *RequestBuilder
SetKeepOrder sets "KeepOrder" for "kv.Request".
func (*RequestBuilder) SetKeyRanges ¶
func (builder *RequestBuilder) SetKeyRanges(keyRanges []kv.KeyRange) *RequestBuilder
SetKeyRanges sets "KeyRanges" for "kv.Request".
func (*RequestBuilder) SetMemTracker ¶
func (builder *RequestBuilder) SetMemTracker(tracker *memory.Tracker) *RequestBuilder
SetMemTracker sets a memTracker for this request.
func (*RequestBuilder) SetPaging ¶
func (builder *RequestBuilder) SetPaging(paging bool) *RequestBuilder
SetPaging sets "Paging" flag for "kv.Request".
func (*RequestBuilder) SetPartitionIDAndRanges ¶
func (builder *RequestBuilder) SetPartitionIDAndRanges(partitionIDAndRanges []kv.PartitionIDAndRanges) *RequestBuilder
SetPartitionIDAndRanges sets `PartitionIDAndRanges` property.
func (*RequestBuilder) SetPartitionKeyRanges ¶
func (builder *RequestBuilder) SetPartitionKeyRanges(keyRanges [][]kv.KeyRange) *RequestBuilder
SetPartitionKeyRanges sets the "KeyRanges" for "kv.Request" on partitioned table cases.
func (*RequestBuilder) SetPartitionsAndHandles ¶
func (builder *RequestBuilder) SetPartitionsAndHandles(handles []kv.Handle) *RequestBuilder
SetPartitionsAndHandles sets "KeyRanges" for "kv.Request" by converting ParitionHandles to KeyRanges. handles in slice must be kv.PartitionHandle.
func (*RequestBuilder) SetReadReplicaScope ¶
func (builder *RequestBuilder) SetReadReplicaScope(scope string) *RequestBuilder
SetReadReplicaScope sets request readReplicaScope
func (*RequestBuilder) SetResourceGroupTagger ¶
func (builder *RequestBuilder) SetResourceGroupTagger(tagger tikvrpc.ResourceGroupTagger) *RequestBuilder
SetResourceGroupTagger sets the request resource group tagger.
func (*RequestBuilder) SetStartTS ¶
func (builder *RequestBuilder) SetStartTS(startTS uint64) *RequestBuilder
SetStartTS sets "StartTS" for "kv.Request".
func (*RequestBuilder) SetStoreType ¶
func (builder *RequestBuilder) SetStoreType(storeType kv.StoreType) *RequestBuilder
SetStoreType sets "StoreType" for "kv.Request".
func (*RequestBuilder) SetTableHandles ¶
func (builder *RequestBuilder) SetTableHandles(tid int64, handles []kv.Handle) *RequestBuilder
SetTableHandles sets "KeyRanges" for "kv.Request" by converting table handles "handles" to "KeyRanges" firstly.
func (*RequestBuilder) SetTableRanges ¶
func (builder *RequestBuilder) SetTableRanges(tid int64, tableRanges []*ranger.Range, fb *statistics.QueryFeedback) *RequestBuilder
SetTableRanges sets "KeyRanges" for "kv.Request" by converting "tableRanges" to "KeyRanges" firstly. Note this function should be deleted or at least not exported, but currently br refers it, so have to keep it.
func (*RequestBuilder) SetTiDBServerID ¶
func (builder *RequestBuilder) SetTiDBServerID(serverID uint64) *RequestBuilder
SetTiDBServerID sets "TiDBServerID" for "kv.Request"
ServerID is a unique id of TiDB instance among the cluster. See https://github.com/wuhuizuo/tidb6/blob/master/docs/design/2020-06-01-global-kill.md
func (*RequestBuilder) SetTxnScope ¶
func (builder *RequestBuilder) SetTxnScope(scope string) *RequestBuilder
SetTxnScope sets request TxnScope
func (*RequestBuilder) SetWrappedKeyRanges ¶
func (builder *RequestBuilder) SetWrappedKeyRanges(keyRanges *kv.KeyRanges) *RequestBuilder
SetWrappedKeyRanges sets "KeyRanges" for "kv.Request".
type SelectResult ¶
type SelectResult interface { // NextRaw gets the next raw result. NextRaw(context.Context) ([]byte, error) // Next reads the data into chunk. Next(context.Context, *chunk.Chunk) error // Close closes the iterator. Close() error }
SelectResult is an iterator of coprocessor partial results.
func Analyze ¶
func Analyze(ctx context.Context, client kv.Client, kvReq *kv.Request, vars interface{}, isRestrict bool, stmtCtx *stmtctx.StatementContext) (SelectResult, error)
Analyze do a analyze request.
func Checksum ¶
func Checksum(ctx context.Context, client kv.Client, kvReq *kv.Request, vars interface{}) (SelectResult, error)
Checksum sends a checksum request.
func DispatchMPPTasks ¶
func DispatchMPPTasks(ctx context.Context, sctx sessionctx.Context, tasks []*kv.MPPDispatchRequest, fieldTypes []*types.FieldType, planIDs []int, rootID int, startTs uint64, memTracker *memory.Tracker) (SelectResult, error)
DispatchMPPTasks dispatches all tasks and returns an iterator.
func NewSerialSelectResults ¶
func NewSerialSelectResults(selectResults []SelectResult) SelectResult
NewSerialSelectResults create a SelectResult which will read each SelectResult serially.
func Select ¶
func Select(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, fieldTypes []*types.FieldType, fb *statistics.QueryFeedback) (SelectResult, error)
Select sends a DAG request, returns SelectResult. In kvReq, KeyRanges is required, Concurrency/KeepOrder/Desc/IsolationLevel/Priority are optional.
func SelectWithRuntimeStats ¶
func SelectWithRuntimeStats(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request, fieldTypes []*types.FieldType, fb *statistics.QueryFeedback, copPlanIDs []int, rootPlanID int) (SelectResult, error)
SelectWithRuntimeStats sends a DAG request, returns SelectResult. The difference from Select is that SelectWithRuntimeStats will set copPlanIDs into selectResult, which can help selectResult to collect runtime stats.