aggregate

package
v1.1.0-beta.0...-5753106 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGroupKey

func GetGroupKey(ctx sessionctx.Context, input *chunk.Chunk, groupKey [][]byte, groupByItems []expression.Expression) ([][]byte, error)

GetGroupKey evaluates the group items and args of aggregate functions.

Types

type AfFinalResult

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

AfFinalResult indicates aggregation functions final result.

type AggSpillDiskAction

type AggSpillDiskAction struct {
	memory.BaseOOMAction
	// contains filtered or unexported fields
}

AggSpillDiskAction implements memory.ActionOnExceed for unparalleled HashAgg. If the memory quota of a query is exceeded, AggSpillDiskAction.Action is triggered.

func (*AggSpillDiskAction) Action

func (a *AggSpillDiskAction) Action(t *memory.Tracker)

Action set HashAggExec spill mode.

func (*AggSpillDiskAction) GetPriority

func (*AggSpillDiskAction) GetPriority() int64

GetPriority get the priority of the Action

type AggWorkerInfo

type AggWorkerInfo struct {
	Concurrency int
	WallTime    int64
}

AggWorkerInfo contains the agg worker information.

type AggWorkerStat

type AggWorkerStat struct {
	TaskNum    int64
	WaitTime   int64
	ExecTime   int64
	WorkerTime int64
}

AggWorkerStat record the AggWorker runtime stat

func (*AggWorkerStat) Clone

func (w *AggWorkerStat) Clone() *AggWorkerStat

Clone implements the RuntimeStats interface.

type HashAggExec

type HashAggExec struct {
	exec.BaseExecutor

	Sc              *stmtctx.StatementContext
	PartialAggFuncs []aggfuncs.AggFunc
	FinalAggFuncs   []aggfuncs.AggFunc

	GroupByItems []expression.Expression

	DefaultVal *chunk.Chunk

	// IsChildReturnEmpty indicates whether the child executor only returns an empty input.
	IsChildReturnEmpty bool
	// After we support parallel execution for aggregation functions with distinct,
	// we can remove this attribute.
	IsUnparallelExec bool
	// contains filtered or unexported fields
}

HashAggExec deals with all the aggregate functions. It is built from the Aggregate Plan. When Next() is called, it reads all the data from Src and updates all the items in PartialAggFuncs. The parallel execution flow is as the following graph shows:

                           +-------------+
                           | Main Thread |
                           +------+------+
                                  ^
                                  |
                                  +
                             +-+-            +-+
                             | |    ......   | |  finalOutputCh
                             +++-            +-+
                              ^
                              |
                              +---------------+
                              |               |
                +--------------+             +--------------+
                | final worker |     ......  | final worker |
                +------------+-+             +-+------------+
                             ^                 ^
                             |                 |
                            +-+  +-+  ......  +-+
                            | |  | |          | |
                            ...  ...          ...    partialOutputChs
                            | |  | |          | |
                            +++  +++          +++
                             ^    ^            ^
         +-+                 |    |            |
         | |        +--------o----+            |
inputCh  +-+        |        +-----------------+---+
         | |        |                              |
         ...    +---+------------+            +----+-----------+
         | |    | partial worker |   ......   | partial worker |
         +++    +--------------+-+            +-+--------------+
          |                     ^                ^
          |                     |                |
     +----v---------+          +++ +-+          +++
     | data fetcher | +------> | | | |  ......  | |   partialInputChs
     +--------------+          +-+ +-+          +-+

func (*HashAggExec) ActionSpill

func (e *HashAggExec) ActionSpill() memory.ActionOnExceed

ActionSpill returns an action for spilling intermediate data for hashAgg.

func (*HashAggExec) Close

func (e *HashAggExec) Close() error

Close implements the Executor Close interface.

func (*HashAggExec) IsSpillTriggeredForTest

func (e *HashAggExec) IsSpillTriggeredForTest() bool

IsSpillTriggeredForTest is for test.

func (*HashAggExec) Next

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

Next implements the Executor Next interface.

func (*HashAggExec) Open

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

Open implements the Executor Open interface.

func (*HashAggExec) OpenSelf

func (e *HashAggExec) OpenSelf() error

OpenSelf just opens the hash aggregation executor.

type HashAggFinalWorker

type HashAggFinalWorker struct {
	BInMap int
	// contains filtered or unexported fields
}

HashAggFinalWorker indicates the final workers of parallel hash agg execution, the number of the worker can be set by `tidb_hashagg_final_concurrency`.

type HashAggInput

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

HashAggInput indicates the input of hash agg exec.

type HashAggPartialWorker

type HashAggPartialWorker struct {
	BInMaps []int
	// contains filtered or unexported fields
}

HashAggPartialWorker indicates the partial workers of parallel hash agg execution, the number of the worker can be set by `tidb_hashagg_partial_concurrency`.

type HashAggRuntimeStats

type HashAggRuntimeStats struct {
	PartialConcurrency int
	PartialWallTime    int64
	FinalConcurrency   int
	FinalWallTime      int64
	PartialStats       []*AggWorkerStat
	FinalStats         []*AggWorkerStat
}

HashAggRuntimeStats record the HashAggExec runtime stat

func (*HashAggRuntimeStats) Clone

Clone implements the RuntimeStats interface.

func (*HashAggRuntimeStats) Merge

Merge implements the RuntimeStats interface.

func (*HashAggRuntimeStats) String

func (e *HashAggRuntimeStats) String() string

String implements the RuntimeStats interface.

func (*HashAggRuntimeStats) Tp

func (*HashAggRuntimeStats) Tp() int

Tp implements the RuntimeStats interface.

type ParallelAggSpillDiskAction

type ParallelAggSpillDiskAction struct {
	memory.BaseOOMAction
	// contains filtered or unexported fields
}

ParallelAggSpillDiskAction implements memory.ActionOnExceed for parallel HashAgg.

func (*ParallelAggSpillDiskAction) Action

Action set HashAggExec spill mode.

func (*ParallelAggSpillDiskAction) GetPriority

func (*ParallelAggSpillDiskAction) GetPriority() int64

GetPriority get the priority of the Action

type StreamAggExec

type StreamAggExec struct {
	exec.BaseExecutor

	// IsChildReturnEmpty indicates whether the child executor only returns an empty input.
	IsChildReturnEmpty bool
	DefaultVal         *chunk.Chunk
	GroupChecker       *vecgroupchecker.VecGroupChecker

	AggFuncs []aggfuncs.AggFunc
	// contains filtered or unexported fields
}

StreamAggExec deals with all the aggregate functions. It assumes all the input data is sorted by group by key. When Next() is called, it will return a result for the same group.

func (*StreamAggExec) Close

func (e *StreamAggExec) Close() error

Close implements the Executor Close interface.

func (*StreamAggExec) Next

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

Next implements the Executor Next interface.

func (*StreamAggExec) Open

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

Open implements the Executor Open interface.

func (*StreamAggExec) OpenSelf

func (e *StreamAggExec) OpenSelf() error

OpenSelf just opens the StreamAggExec.

Jump to

Keyboard shortcuts

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