pattern

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

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

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

Documentation

Index

Constants

View Source
const (
	// EngineTiDBOnly is the EngineTypeSet for EngineTiDB only.
	EngineTiDBOnly = EngineTypeSet(EngineTiDB)
	// EngineTiKVOnly is the EngineTypeSet for EngineTiKV only.
	EngineTiKVOnly = EngineTypeSet(EngineTiKV)
	// EngineTiFlashOnly is the EngineTypeSet for EngineTiFlash only.
	EngineTiFlashOnly = EngineTypeSet(EngineTiFlash)
	// EngineTiKVOrTiFlash is the EngineTypeSet for (EngineTiKV | EngineTiFlash).
	EngineTiKVOrTiFlash = EngineTypeSet(EngineTiKV | EngineTiFlash)
	// EngineAll is the EngineTypeSet for all of the EngineTypes.
	EngineAll = EngineTypeSet(EngineTiDB | EngineTiKV | EngineTiFlash)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EngineType

type EngineType uint

EngineType is determined by whether it's above or below `Gather`s. Plan will choose the different engine to be implemented/executed on according to its EngineType. Different engine may support different operators with different cost, so we should design different transformation and implementation rules for each engine.

const (
	// EngineTiDB stands for groups which is above `Gather`s and will be executed in TiDB layer.
	EngineTiDB EngineType = 1 << iota
	// EngineTiKV stands for groups which is below `Gather`s and will be executed in TiKV layer.
	EngineTiKV
	// EngineTiFlash stands for groups which is below `Gather`s and will be executed in TiFlash layer.
	EngineTiFlash
)

func (EngineType) String

func (e EngineType) String() string

String implements fmt.Stringer interface.

type EngineTypeSet

type EngineTypeSet uint

EngineTypeSet is the bit set of EngineTypes.

func (EngineTypeSet) Contains

func (e EngineTypeSet) Contains(tp EngineType) bool

Contains checks whether the EngineTypeSet contains the EngineType.

type Operand

type Operand int

Operand is the node of a pattern tree, it represents a logical expression operator. Different from logical plan operator which holds the full information about an expression operator, Operand only stores the type information. An Operand may correspond to a concrete logical plan operator, or it can has special meaning, e.g, a placeholder for any logical plan operator.

const (
	// OperandAny is a placeholder for any Operand.
	OperandAny Operand = iota
	// OperandJoin is the operand for LogicalJoin.
	OperandJoin
	// OperandAggregation is the operand for LogicalAggregation.
	OperandAggregation
	// OperandProjection is the operand for LogicalProjection.
	OperandProjection
	// OperandSelection is the operand for LogicalSelection.
	OperandSelection
	// OperandApply is the operand for LogicalApply.
	OperandApply
	// OperandMaxOneRow is the operand for LogicalMaxOneRow.
	OperandMaxOneRow
	// OperandTableDual is the operand for LogicalTableDual.
	OperandTableDual
	// OperandDataSource is the operand for DataSource.
	OperandDataSource
	// OperandUnionScan is the operand for LogicalUnionScan.
	OperandUnionScan
	// OperandUnionAll is the operand for LogicalUnionAll.
	OperandUnionAll
	// OperandSort is the operand for LogicalSort.
	OperandSort
	// OperandTopN is the operand for LogicalTopN.
	OperandTopN
	// OperandLock is the operand for LogicalLock.
	OperandLock
	// OperandLimit is the operand for LogicalLimit.
	OperandLimit
	// OperandTiKVSingleGather is the operand for TiKVSingleGather.
	OperandTiKVSingleGather
	// OperandMemTableScan is the operand for MemTableScan.
	OperandMemTableScan
	// OperandTableScan is the operand for TableScan.
	OperandTableScan
	// OperandIndexScan is the operand for IndexScan.
	OperandIndexScan
	// OperandShow is the operand for Show.
	OperandShow
	// OperandWindow is the operand for window function.
	OperandWindow
	// OperandUnsupported is the operand for unsupported operators.
	OperandUnsupported
)

func GetOperand

func GetOperand(p base.LogicalPlan) Operand

GetOperand maps logical plan operator to Operand.

func (Operand) Match

func (o Operand) Match(t Operand) bool

Match checks if current Operand matches specified one.

func (Operand) String

func (o Operand) String() string

String implements fmt.Stringer interface.

type Pattern

type Pattern struct {
	Operand
	EngineTypeSet
	Children []*Pattern
}

Pattern defines the match pattern for a rule. It's a tree-like structure which is a piece of a logical expression. Each node in the Pattern tree is defined by an Operand and EngineType pair.

func BuildPattern

func BuildPattern(operand Operand, engineTypeSet EngineTypeSet, children ...*Pattern) *Pattern

BuildPattern builds a Pattern from Operand, EngineType and child Patterns. Used in GetPattern() of Transformation interface to generate a Pattern.

func NewPattern

func NewPattern(operand Operand, engineTypeSet EngineTypeSet) *Pattern

NewPattern creates a pattern node according to the Operand and EngineType.

func (*Pattern) Match

func (p *Pattern) Match(o Operand, e EngineType) bool

Match checks whether the EngineTypeSet contains the given EngineType and whether the two Operands match.

func (*Pattern) MatchOperandAny

func (p *Pattern) MatchOperandAny(e EngineType) bool

MatchOperandAny checks whether the pattern's Operand is OperandAny and the EngineTypeSet contains the given EngineType.

func (*Pattern) SetChildren

func (p *Pattern) SetChildren(children ...*Pattern)

SetChildren sets the Children information for a pattern node.

Jump to

Keyboard shortcuts

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