exec

package
v0.0.0-...-6e93ed8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(e Executor) (err error)

Close is a wrapper function on e.Close(), it handles some common codes.

func NewFirstChunk

func NewFirstChunk(e Executor) *chunk.Chunk

NewFirstChunk creates a new chunk to buffer current executor's result.

func Next

func Next(ctx context.Context, e Executor, req *chunk.Chunk) (err error)

Next is a wrapper function on e.Next(), it handles some common codes.

func Open

func Open(ctx context.Context, e Executor) (err error)

Open is a wrapper function on e.Open(), it handles some common codes.

func RetTypes

func RetTypes(e Executor) []*types.FieldType

RetTypes returns all output column types.

func TryNewCacheChunk

func TryNewCacheChunk(e Executor) *chunk.Chunk

TryNewCacheChunk tries to get a cached chunk

Types

type BaseExecutor

type BaseExecutor struct {
	BaseExecutorV2
	// contains filtered or unexported fields
}

BaseExecutor holds common information for executors.

func NewBaseExecutor

func NewBaseExecutor(ctx sessionctx.Context, schema *expression.Schema, id int, children ...Executor) BaseExecutor

NewBaseExecutor creates a new BaseExecutor instance.

func (*BaseExecutor) AllChildren

func (e *BaseExecutor) AllChildren() []Executor

AllChildren returns all children.

func (*BaseExecutor) Children

func (e *BaseExecutor) Children(idx int) Executor

Children returns the children for an executor.

func (*BaseExecutor) ChildrenLen

func (e *BaseExecutor) ChildrenLen() int

ChildrenLen returns the length of children.

func (*BaseExecutor) Ctx

func (e *BaseExecutor) Ctx() sessionctx.Context

Ctx return ```sessionctx.Context``` of Executor

func (*BaseExecutor) EmptyChildren

func (e *BaseExecutor) EmptyChildren() bool

EmptyChildren judges whether the children is empty.

func (*BaseExecutor) GetSchema

func (e *BaseExecutor) GetSchema() *expression.Schema

GetSchema gets the schema.

func (*BaseExecutor) GetSysSession

func (e *BaseExecutor) GetSysSession() (sessionctx.Context, error)

GetSysSession gets a system session context from executor.

func (*BaseExecutor) HandleSQLKillerSignal

func (e *BaseExecutor) HandleSQLKillerSignal() error

func (*BaseExecutor) ID

func (e *BaseExecutor) ID() int

ID returns the id of an executor.

func (*BaseExecutor) InitCap

func (e *BaseExecutor) InitCap() int

InitCap returns the initial capacity for chunk

func (*BaseExecutor) MaxChunkSize

func (e *BaseExecutor) MaxChunkSize() int

MaxChunkSize returns the max chunk size.

func (*BaseExecutor) NewChunk

func (e *BaseExecutor) NewChunk() *chunk.Chunk

NewChunk creates a new chunk according to the executor configuration

func (*BaseExecutor) NewChunkWithCapacity

func (e *BaseExecutor) NewChunkWithCapacity(fields []*types.FieldType, capacity int, maxCachesize int) *chunk.Chunk

NewChunkWithCapacity allows the caller to allocate the chunk with any types, capacity and max size in the pool

func (*BaseExecutor) RegisterSQLAndPlanInExecForTopSQL

func (e *BaseExecutor) RegisterSQLAndPlanInExecForTopSQL()

RegisterSQLAndPlanInExecForTopSQL registers the current SQL and Plan on top sql

func (*BaseExecutor) ReleaseSysSession

func (e *BaseExecutor) ReleaseSysSession(ctx context.Context, sctx sessionctx.Context)

ReleaseSysSession releases a system session context to executor.

func (*BaseExecutor) RetFieldTypes

func (e *BaseExecutor) RetFieldTypes() []*types.FieldType

NewChunkWithCapacity allows the caller to allocate the chunk with any types, capacity and max size in the pool

func (*BaseExecutor) RuntimeStats

func (e *BaseExecutor) RuntimeStats() *execdetails.BasicRuntimeStats

RuntimeStats returns the runtime stats of an executor.

func (*BaseExecutor) Schema

func (e *BaseExecutor) Schema() *expression.Schema

Schema returns the current BaseExecutor's schema. If it is nil, then create and return a new one.

func (*BaseExecutor) SetAllChildren

func (e *BaseExecutor) SetAllChildren(children []Executor)

SetAllChildren sets the children for an executor.

func (*BaseExecutor) SetChildren

func (e *BaseExecutor) SetChildren(idx int, ex Executor)

SetChildren sets a child for an executor.

func (*BaseExecutor) SetInitCap

func (e *BaseExecutor) SetInitCap(c int)

SetInitCap sets the initial capacity for chunk

func (*BaseExecutor) SetMaxChunkSize

func (e *BaseExecutor) SetMaxChunkSize(size int)

SetMaxChunkSize sets the max chunk size.

func (*BaseExecutor) UpdateDeltaForTableID

func (e *BaseExecutor) UpdateDeltaForTableID(id int64)

UpdateDeltaForTableID updates the delta info for the table with tableID.

type BaseExecutorV2

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

BaseExecutorV2 is a simplified version of `BaseExecutor`, which doesn't contain a full session context

func NewBaseExecutorV2

func NewBaseExecutorV2(vars *variable.SessionVars, schema *expression.Schema, id int, children ...Executor) BaseExecutorV2

NewBaseExecutorV2 creates a new BaseExecutorV2 instance.

func (*BaseExecutorV2) AllChildren

func (e *BaseExecutorV2) AllChildren() []Executor

AllChildren returns all children.

func (*BaseExecutorV2) BuildNewBaseExecutorV2

func (e *BaseExecutorV2) BuildNewBaseExecutorV2(stmtRuntimeStatsColl *execdetails.RuntimeStatsColl, schema *expression.Schema, id int, children ...Executor) BaseExecutorV2

BuildNewBaseExecutorV2 builds a new `BaseExecutorV2` based on the configuration of the current base executor. It's used to build a new sub-executor from an existing executor. For example, the `IndexLookUpExecutor` will use this function to build `TableReaderExecutor`

func (*BaseExecutorV2) Children

func (e *BaseExecutorV2) Children(idx int) Executor

Children returns the children for an executor.

func (*BaseExecutorV2) ChildrenLen

func (e *BaseExecutorV2) ChildrenLen() int

ChildrenLen returns the length of children.

func (*BaseExecutorV2) Close

func (e *BaseExecutorV2) Close() error

Close closes all executors and release all resources.

func (*BaseExecutorV2) Detach

func (*BaseExecutorV2) Detach() (Executor, bool)

Detach detaches the current executor from the session context.

func (*BaseExecutorV2) EmptyChildren

func (e *BaseExecutorV2) EmptyChildren() bool

EmptyChildren judges whether the children is empty.

func (*BaseExecutorV2) GetSchema

func (e *BaseExecutorV2) GetSchema() *expression.Schema

GetSchema gets the schema.

func (*BaseExecutorV2) HandleSQLKillerSignal

func (e *BaseExecutorV2) HandleSQLKillerSignal() error

func (*BaseExecutorV2) ID

func (e *BaseExecutorV2) ID() int

ID returns the id of an executor.

func (*BaseExecutorV2) InitCap

func (e *BaseExecutorV2) InitCap() int

InitCap returns the initial capacity for chunk

func (*BaseExecutorV2) MaxChunkSize

func (e *BaseExecutorV2) MaxChunkSize() int

MaxChunkSize returns the max chunk size.

func (*BaseExecutorV2) NewChunk

func (e *BaseExecutorV2) NewChunk() *chunk.Chunk

NewChunk creates a new chunk according to the executor configuration

func (*BaseExecutorV2) NewChunkWithCapacity

func (e *BaseExecutorV2) NewChunkWithCapacity(fields []*types.FieldType, capacity int, maxCachesize int) *chunk.Chunk

NewChunkWithCapacity allows the caller to allocate the chunk with any types, capacity and max size in the pool

func (*BaseExecutorV2) Next

Next fills multiple rows into a chunk.

func (*BaseExecutorV2) Open

func (e *BaseExecutorV2) Open(ctx context.Context) error

Open initializes children recursively and "childrenResults" according to children's schemas.

func (*BaseExecutorV2) RegisterSQLAndPlanInExecForTopSQL

func (e *BaseExecutorV2) RegisterSQLAndPlanInExecForTopSQL()

RegisterSQLAndPlanInExecForTopSQL registers the current SQL and Plan on top sql

func (*BaseExecutorV2) RetFieldTypes

func (e *BaseExecutorV2) RetFieldTypes() []*types.FieldType

NewChunkWithCapacity allows the caller to allocate the chunk with any types, capacity and max size in the pool

func (*BaseExecutorV2) RuntimeStats

func (e *BaseExecutorV2) RuntimeStats() *execdetails.BasicRuntimeStats

RuntimeStats returns the runtime stats of an executor.

func (*BaseExecutorV2) Schema

func (e *BaseExecutorV2) Schema() *expression.Schema

Schema returns the current BaseExecutor's schema. If it is nil, then create and return a new one.

func (*BaseExecutorV2) SetAllChildren

func (e *BaseExecutorV2) SetAllChildren(children []Executor)

SetAllChildren sets the children for an executor.

func (*BaseExecutorV2) SetChildren

func (e *BaseExecutorV2) SetChildren(idx int, ex Executor)

SetChildren sets a child for an executor.

func (*BaseExecutorV2) SetInitCap

func (e *BaseExecutorV2) SetInitCap(c int)

SetInitCap sets the initial capacity for chunk

func (*BaseExecutorV2) SetMaxChunkSize

func (e *BaseExecutorV2) SetMaxChunkSize(size int)

SetMaxChunkSize sets the max chunk size.

type Executor

type Executor interface {
	NewChunk() *chunk.Chunk
	NewChunkWithCapacity(fields []*types.FieldType, capacity int, maxCachesize int) *chunk.Chunk

	RuntimeStats() *execdetails.BasicRuntimeStats

	HandleSQLKillerSignal() error
	RegisterSQLAndPlanInExecForTopSQL()

	AllChildren() []Executor
	SetAllChildren([]Executor)
	Open(context.Context) error
	Next(ctx context.Context, req *chunk.Chunk) error

	// `Close()` may be called at any time after `Open()` and it may be called with `Next()` at the same time
	Close() error
	Schema() *expression.Schema
	RetFieldTypes() []*types.FieldType
	InitCap() int
	MaxChunkSize() int

	// Detach detaches the current executor from the session context without considering its children.
	//
	// It has to make sure, no matter whether it returns true or false, both the original executor and the returning executor
	// should be able to be used correctly.
	Detach() (Executor, bool)
}

Executor is the physical implementation of an algebra operator.

In TiDB, all algebra operators are implemented as iterators, i.e., they support a simple Open-Next-Close protocol. See this paper for more details:

"Volcano-An Extensible and Parallel Query Evaluation System"

Different from Volcano's execution model, a "Next" function call in TiDB will return a batch of rows, other than a single row in Volcano. NOTE: Executors must call "chk.Reset()" before appending their results to it.

type IndexUsageReporter

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

IndexUsageReporter is a toolkit to report index usage

func NewIndexUsageReporter

func NewIndexUsageReporter(reporter *indexusage.StmtIndexUsageCollector,
	runtimeStatsColl *execdetails.RuntimeStatsColl,
	statsMap *stmtctx.UsedStatsInfo) *IndexUsageReporter

NewIndexUsageReporter creates an index usage reporter util

func (*IndexUsageReporter) ReportCopIndexUsage

func (e *IndexUsageReporter) ReportCopIndexUsage(tableID int64, physicalTableID int64, indexID int64, planID int)

ReportCopIndexUsage reports the index usage to the inside collector. The index usage will be recorded in the `tableID+indexID`, but the percentage is calculated using the size of the table specified by `physicalTableID`.

func (*IndexUsageReporter) ReportCopIndexUsageForHandle

func (e *IndexUsageReporter) ReportCopIndexUsageForHandle(tbl table.Table, planID int)

ReportCopIndexUsageForHandle wraps around `ReportCopIndexUsageForTable` to get the `indexID` automatically from the `table.Table` if the table has a clustered index or integer primary key.

func (*IndexUsageReporter) ReportCopIndexUsageForTable

func (e *IndexUsageReporter) ReportCopIndexUsageForTable(tbl table.Table, indexID int64, planID int)

ReportCopIndexUsageForTable wraps around `ReportCopIndexUsage` to get `tableID` and `physicalTableID` from the `table.Table`. If it's expected to calculate the percentage according to the size of partition, the `tbl` argument should be a `table.PhysicalTable`, or the percentage will be calculated using the size of whole table.

func (*IndexUsageReporter) ReportPointGetIndexUsage

func (e *IndexUsageReporter) ReportPointGetIndexUsage(tableID int64, physicalTableID int64, indexID int64, planID int, kvRequestTotal int64)

ReportPointGetIndexUsage reports the index usage of a point get or batch point get

func (*IndexUsageReporter) ReportPointGetIndexUsageForHandle

func (e *IndexUsageReporter) ReportPointGetIndexUsageForHandle(tblInfo *model.TableInfo, physicalTableID int64, planID int, kvRequestTotal int64)

ReportPointGetIndexUsageForHandle wraps around `ReportPointGetIndexUsage` to get the `indexID` automatically from the `table.Table` if the table has a clustered index or integer primary key.

Jump to

Keyboard shortcuts

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