planner

package
v0.0.0-...-959c02d Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RewriteExpr

func RewriteExpr(expr ast.ExprNode, p LogicalPlan) (expression.Expression, error)

Types

type Builder

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

Builder is used to build the AST into a plan.

func NewBuilder

func NewBuilder(sc *stmtctx.Context) *Builder

NewBuilder returns a plan builder.

func (*Builder) Build

func (b *Builder) Build(node ast.StmtNode) (Plan, error)

Build builds a statement AST node into a Plan.

type ByItem

type ByItem struct {
	Expr      expression.Expression
	AsName    model.CIStr
	Desc      bool
	NullOrder bool
}

ByItem wraps a "by" item.

func (*ByItem) String

func (by *ByItem) String() string

String implements fmt.Stringer interface.

type CommonPathExpression

type CommonPathExpression struct {
	Leftmost    *Vertex
	Rightmost   *Vertex
	Vertices    map[string]*Vertex
	Connections map[string]VertexPairConnection
	Constraints ast.ExprNode
	// contains filtered or unexported fields
}

func (*CommonPathExpression) AnyDirected

func (b *CommonPathExpression) AnyDirected() bool

func (*CommonPathExpression) DstVarName

func (b *CommonPathExpression) DstVarName() model.CIStr

func (*CommonPathExpression) Name

func (b *CommonPathExpression) Name() model.CIStr

func (*CommonPathExpression) SetAnyDirected

func (b *CommonPathExpression) SetAnyDirected(anyDirected bool)

func (*CommonPathExpression) SetDstVarName

func (b *CommonPathExpression) SetDstVarName(name model.CIStr)

func (*CommonPathExpression) SetName

func (b *CommonPathExpression) SetName(name model.CIStr)

func (*CommonPathExpression) SetSrcVarName

func (b *CommonPathExpression) SetSrcVarName(name model.CIStr)

func (*CommonPathExpression) SrcVarName

func (b *CommonPathExpression) SrcVarName() model.CIStr

type DDL

type DDL struct {
	Statement ast.DDLNode
	// contains filtered or unexported fields
}

DDL represents the physical plan of DDL statement.

func (*DDL) Columns

func (p *DDL) Columns() ResultColumns

Columns implements the Plan.Columns interface.

func (*DDL) ExplainID

func (p *DDL) ExplainID() string

ExplainID implements the Plan interface.

func (*DDL) ExplainInfo

func (*DDL) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*DDL) ID

func (p *DDL) ID() int

ID implements the Plan interface.

func (*DDL) SetColumns

func (p *DDL) SetColumns(cols ResultColumns)

func (*DDL) TP

func (p *DDL) TP() string

TP implements the Plan interface.

type Edge

type Edge struct {
	Labels []*catalog.Label
	// contains filtered or unexported fields
}

func (*Edge) AnyDirected

func (b *Edge) AnyDirected() bool

func (*Edge) DstVarName

func (b *Edge) DstVarName() model.CIStr

func (*Edge) Name

func (b *Edge) Name() model.CIStr

func (*Edge) SetAnyDirected

func (b *Edge) SetAnyDirected(anyDirected bool)

func (*Edge) SetDstVarName

func (b *Edge) SetDstVarName(name model.CIStr)

func (*Edge) SetName

func (b *Edge) SetName(name model.CIStr)

func (*Edge) SetSrcVarName

func (b *Edge) SetSrcVarName(name model.CIStr)

func (*Edge) SrcVarName

func (b *Edge) SrcVarName() model.CIStr

type ElementInsertion

type ElementInsertion struct {
	Type ast.InsertionType
	// INSERT EDGE e BETWEEN x AND y FROM MATCH (x) , MATCH (y) WHERE id(x) = 1 AND id(y) = 2
	// FromIDExpr and ToIDExpr are the expressions to get the ID of the source and destination vertex.
	FromIDExpr  expression.Expression
	ToIDExpr    expression.Expression
	Labels      []*catalog.Label
	Assignments []*expression.Assignment
}

ElementInsertion represents a graph insertion element.

type GraphVar

type GraphVar struct {
	Name      model.CIStr
	Anonymous bool
}

GraphVar represents a graph variable in a MATCH clause.

type Insert

type Insert struct {
	Graph      *catalog.Graph
	Insertions []*ElementInsertion
	MatchPlan  Plan
	// contains filtered or unexported fields
}

Insert represents the plan of INSERT statement.

func (*Insert) Columns

func (p *Insert) Columns() ResultColumns

Columns implements the Plan.Columns interface.

func (*Insert) ExplainID

func (p *Insert) ExplainID() string

ExplainID implements the Plan interface.

func (*Insert) ExplainInfo

func (*Insert) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*Insert) ID

func (p *Insert) ID() int

ID implements the Plan interface.

func (*Insert) SetColumns

func (p *Insert) SetColumns(cols ResultColumns)

func (*Insert) TP

func (p *Insert) TP() string

TP implements the Plan interface.

type LogicalDual

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

LogicalDual represents the plan which returns empty result set.

func (*LogicalDual) Children

func (p *LogicalDual) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalDual) Columns

func (p *LogicalDual) Columns() ResultColumns

func (*LogicalDual) SetChild

func (p *LogicalDual) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalDual) SetChildren

func (p *LogicalDual) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type LogicalLimit

type LogicalLimit struct {
	Offset expression.Expression
	Count  expression.Expression
	// contains filtered or unexported fields
}

func (*LogicalLimit) Children

func (p *LogicalLimit) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalLimit) Columns

func (p *LogicalLimit) Columns() ResultColumns

func (*LogicalLimit) SetChild

func (p *LogicalLimit) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalLimit) SetChildren

func (p *LogicalLimit) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type LogicalMatch

type LogicalMatch struct {
	Subgraph *Subgraph
	// contains filtered or unexported fields
}

func (*LogicalMatch) Children

func (p *LogicalMatch) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalMatch) Columns

func (p *LogicalMatch) Columns() ResultColumns

func (*LogicalMatch) SetChild

func (p *LogicalMatch) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalMatch) SetChildren

func (p *LogicalMatch) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type LogicalPlan

type LogicalPlan interface {
	Plan

	// Children returns all the children.
	Children() []LogicalPlan
	// SetChildren sets the children for the plan.
	SetChildren(...LogicalPlan)
	// SetChild sets the ith child for the plan.
	SetChild(i int, child LogicalPlan)
}

type LogicalProjection

type LogicalProjection struct {
	Exprs []expression.Expression
	// contains filtered or unexported fields
}

func (*LogicalProjection) Children

func (p *LogicalProjection) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalProjection) Columns

func (p *LogicalProjection) Columns() ResultColumns

func (*LogicalProjection) SetChild

func (p *LogicalProjection) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalProjection) SetChildren

func (p *LogicalProjection) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type LogicalSelection

type LogicalSelection struct {
	Condition expression.Expression
	// contains filtered or unexported fields
}

func (*LogicalSelection) Children

func (p *LogicalSelection) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalSelection) Columns

func (p *LogicalSelection) Columns() ResultColumns

func (*LogicalSelection) SetChild

func (p *LogicalSelection) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalSelection) SetChildren

func (p *LogicalSelection) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type LogicalSort

type LogicalSort struct {
	ByItems []*ByItem
	// contains filtered or unexported fields
}

func (*LogicalSort) Children

func (p *LogicalSort) Children() []LogicalPlan

Children implements LogicalPlan Children interface.

func (*LogicalSort) Columns

func (p *LogicalSort) Columns() ResultColumns

func (*LogicalSort) SetChild

func (p *LogicalSort) SetChild(i int, child LogicalPlan)

SetChild implements LogicalPlan SetChild interface.

func (*LogicalSort) SetChildren

func (p *LogicalSort) SetChildren(children ...LogicalPlan)

SetChildren implements LogicalPlan SetChildren interface.

type PathFindingGoal

type PathFindingGoal int
const (
	PathFindingAll PathFindingGoal = iota
	PathFindingReaches
	PathFindingShortest
	PathFindingCheapest
)

type PhysicalLimit

type PhysicalLimit struct {
	Offset expression.Expression
	Count  expression.Expression
	// contains filtered or unexported fields
}

func (*PhysicalLimit) Children

func (p *PhysicalLimit) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalLimit) Columns

func (p *PhysicalLimit) Columns() ResultColumns

func (*PhysicalLimit) SetChild

func (p *PhysicalLimit) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalLimit) SetChildren

func (p *PhysicalLimit) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

type PhysicalMatch

type PhysicalMatch struct {
	Subgraph *Subgraph
	// contains filtered or unexported fields
}

func (*PhysicalMatch) Children

func (p *PhysicalMatch) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalMatch) Columns

func (p *PhysicalMatch) Columns() ResultColumns

func (*PhysicalMatch) SetChild

func (p *PhysicalMatch) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalMatch) SetChildren

func (p *PhysicalMatch) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

type PhysicalPlan

type PhysicalPlan interface {
	Plan

	// Children returns all the children.
	Children() []PhysicalPlan
	// SetChildren sets the children for the plan.
	SetChildren(...PhysicalPlan)
	// SetChild sets the ith child for the plan.
	SetChild(i int, child PhysicalPlan)
}

type PhysicalProjection

type PhysicalProjection struct {
	Exprs []expression.Expression
	// contains filtered or unexported fields
}

func (*PhysicalProjection) Children

func (p *PhysicalProjection) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalProjection) Columns

func (p *PhysicalProjection) Columns() ResultColumns

func (*PhysicalProjection) SetChild

func (p *PhysicalProjection) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalProjection) SetChildren

func (p *PhysicalProjection) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

type PhysicalSelection

type PhysicalSelection struct {
	Condition expression.Expression
	// contains filtered or unexported fields
}

func (*PhysicalSelection) Children

func (p *PhysicalSelection) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalSelection) Columns

func (p *PhysicalSelection) Columns() ResultColumns

func (*PhysicalSelection) SetChild

func (p *PhysicalSelection) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalSelection) SetChildren

func (p *PhysicalSelection) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

type PhysicalSort

type PhysicalSort struct {
	ByItems []*ByItem
	// contains filtered or unexported fields
}

func (*PhysicalSort) Children

func (p *PhysicalSort) Children() []PhysicalPlan

Children implements PhysicalPlan Children interface.

func (*PhysicalSort) Columns

func (p *PhysicalSort) Columns() ResultColumns

func (*PhysicalSort) SetChild

func (p *PhysicalSort) SetChild(i int, child PhysicalPlan)

SetChild implements PhysicalPlan SetChild interface.

func (*PhysicalSort) SetChildren

func (p *PhysicalSort) SetChildren(children ...PhysicalPlan)

SetChildren implements PhysicalPlan SetChildren interface.

type Plan

type Plan interface {
	// ID gets the ID.
	ID() int
	// TP gets the plan type.
	TP() string
	// Columns gets the result columns.
	Columns() ResultColumns
	// SetColumns sets the result columns
	SetColumns(cols ResultColumns)
	// ExplainID gets the ID in explain statement
	ExplainID() string
	// ExplainInfo returns operator information to be explained.
	ExplainInfo() string
}

func Optimize

func Optimize(plan LogicalPlan) Plan

Optimize optimizes the plan to the optimal physical plan.

type ResultColumn

type ResultColumn struct {
	Name   model.CIStr
	Type   types.T
	Hidden bool
}

type ResultColumns

type ResultColumns []ResultColumn

func ResultColumnsFromSubgraph

func ResultColumnsFromSubgraph(sg *Subgraph) ResultColumns

func (ResultColumns) FindColumnIndex

func (r ResultColumns) FindColumnIndex(name model.CIStr) int

type Simple

type Simple struct {
	Statement ast.StmtNode
	// contains filtered or unexported fields
}

Simple represents the physical plan of simple statements.

func (*Simple) Columns

func (p *Simple) Columns() ResultColumns

Columns implements the Plan.Columns interface.

func (*Simple) ExplainID

func (p *Simple) ExplainID() string

ExplainID implements the Plan interface.

func (*Simple) ExplainInfo

func (*Simple) ExplainInfo() string

ExplainInfo implements Plan interface.

func (*Simple) ID

func (p *Simple) ID() int

ID implements the Plan interface.

func (*Simple) SetColumns

func (p *Simple) SetColumns(cols ResultColumns)

func (*Simple) TP

func (p *Simple) TP() string

TP implements the Plan interface.

type Subgraph

type Subgraph struct {
	Vertices      map[string]*Vertex
	Connections   map[string]VertexPairConnection
	SingletonVars []*GraphVar
	GroupVars     []*GraphVar
}

type SubgraphBuilder

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

func NewSubgraphBuilder

func NewSubgraphBuilder(graph *catalog.Graph) *SubgraphBuilder

func (*SubgraphBuilder) AddPathPatternMacros

func (s *SubgraphBuilder) AddPathPatternMacros(macros ...*ast.PathPatternMacro) *SubgraphBuilder

func (*SubgraphBuilder) AddPathPatterns

func (s *SubgraphBuilder) AddPathPatterns(paths ...*ast.PathPattern) *SubgraphBuilder

func (*SubgraphBuilder) Build

func (s *SubgraphBuilder) Build() (*Subgraph, error)

type VariableLengthPath

type VariableLengthPath struct {
	Conn        VertexPairConnection
	Goal        PathFindingGoal
	MinHops     int64
	MaxHops     int64
	TopK        int64
	WithTies    bool
	Constraints ast.ExprNode
	Cost        ast.ExprNode
	HopSrc      *Vertex
	HopDst      *Vertex
	// contains filtered or unexported fields
}

func (*VariableLengthPath) AnyDirected

func (b *VariableLengthPath) AnyDirected() bool

func (*VariableLengthPath) DstVarName

func (b *VariableLengthPath) DstVarName() model.CIStr

func (*VariableLengthPath) Name

func (b *VariableLengthPath) Name() model.CIStr

func (*VariableLengthPath) SetAnyDirected

func (b *VariableLengthPath) SetAnyDirected(anyDirected bool)

func (*VariableLengthPath) SetDstVarName

func (b *VariableLengthPath) SetDstVarName(name model.CIStr)

func (*VariableLengthPath) SetName

func (b *VariableLengthPath) SetName(name model.CIStr)

func (*VariableLengthPath) SetSrcVarName

func (b *VariableLengthPath) SetSrcVarName(name model.CIStr)

func (*VariableLengthPath) SrcVarName

func (b *VariableLengthPath) SrcVarName() model.CIStr

type Vertex

type Vertex struct {
	Name   model.CIStr
	Labels []*catalog.Label
}

type VertexPairConnection

type VertexPairConnection interface {
	Name() model.CIStr
	AnyDirected() bool
	SetAnyDirected(anyDirected bool)
	SrcVarName() model.CIStr
	SetSrcVarName(name model.CIStr)
	DstVarName() model.CIStr
	SetDstVarName(name model.CIStr)
}

VertexPairConnection represents a connection between two vertices.

Jump to

Keyboard shortcuts

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