memo

package
v0.0.0-...-3633c1a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExprIter

type ExprIter struct {
	// Group and Element solely identify a Group expression.
	*Group
	*list.Element

	// Operand is the node of the pattern tree. The Operand type of the Group
	// expression must be matched with it.
	Operand

	// Children is used to iterate the child expressions.
	Children []*ExprIter
	// contains filtered or unexported fields
}

ExprIter enumerates all the equivalent expressions in the Group according to the expression pattern.

func NewExprIterFromGroupElem

func NewExprIterFromGroupElem(elem *list.Element, p *Pattern) *ExprIter

NewExprIterFromGroupElem creates the iterator on the Group Element.

func (*ExprIter) Matched

func (iter *ExprIter) Matched() bool

Matched returns whether the iterator founds a Group expression matches the pattern.

func (*ExprIter) Next

func (iter *ExprIter) Next() (found bool)

Next returns the next Group expression matches the pattern.

func (*ExprIter) Reset

func (iter *ExprIter) Reset() (findMatch bool)

Reset resets the iterator to the first matched Group expression.

type Group

type Group struct {
	Equivalents *list.List

	FirstExpr    map[Operand]*list.Element
	Fingerprints map[string]*list.Element

	Explored        bool
	SelfFingerprint string

	ImplMap map[string]Implementation
	Prop    *property.LogicalProperty
}

Group is short for expression Group, which is used to store all the logically equivalent expressions. It's a set of GroupExpr.

func NewGroup

func NewGroup(e *GroupExpr) *Group

NewGroup creates a new Group.

func (*Group) Delete

func (g *Group) Delete(e *GroupExpr)

Delete an existing Group expression.

func (*Group) Exists

func (g *Group) Exists(e *GroupExpr) bool

Exists checks whether a Group expression existed in a Group.

func (*Group) FingerPrint

func (g *Group) FingerPrint() string

FingerPrint returns the unique fingerprint of the Group.

func (*Group) GetFirstElem

func (g *Group) GetFirstElem(operand Operand) *list.Element

GetFirstElem returns the first Group expression which matches the Operand. Return a nil pointer if there isn't.

func (*Group) GetImpl

func (g *Group) GetImpl(prop *property.PhysicalProperty) Implementation

GetImpl returns the best Implementation satisfy the physical property.

func (*Group) Insert

func (g *Group) Insert(e *GroupExpr) bool

Insert a nonexistent Group expression.

func (*Group) InsertImpl

func (g *Group) InsertImpl(prop *property.PhysicalProperty, impl Implementation)

InsertImpl inserts the best Implementation satisfy the physical property.

type GroupExpr

type GroupExpr struct {
	ExprNode plannercore.LogicalPlan
	Children []*Group
	Explored bool
	// contains filtered or unexported fields
}

GroupExpr is used to store all the logically equivalent expressions which have the same root operator. Different from a normal expression, the Children of a Group expression are expression Groups, not expressions. Another property of Group expression is that the child Group references will never be changed once the Group expression is created.

func NewGroupExpr

func NewGroupExpr(node plannercore.LogicalPlan) *GroupExpr

NewGroupExpr creates a GroupExpr based on a logical plan node.

func (*GroupExpr) FingerPrint

func (e *GroupExpr) FingerPrint() string

FingerPrint gets the unique fingerprint of the Group expression.

type Implementation

type Implementation interface {
	CalcCost(outCount float64, childCosts []float64, children ...*Group) float64
	SetCost(cost float64)
	GetCost() float64
	GetPlan() plannercore.PhysicalPlan
}

Implementation defines the interface for cost of physical plan.

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 for LogicalJoin.
	OperandJoin
	// OperandAggregation for LogicalAggregation.
	OperandAggregation
	// OperandProjection for LogicalProjection.
	OperandProjection
	// OperandSelection for LogicalSelection.
	OperandSelection
	// OperandApply for LogicalApply.
	OperandApply
	// OperandMaxOneRow for LogicalMaxOneRow.
	OperandMaxOneRow
	// OperandTableDual for LogicalTableDual.
	OperandTableDual
	// OperandDataSource for DataSource.
	OperandDataSource
	// OperandUnionScan for LogicalUnionScan.
	OperandUnionScan
	// OperandUnionAll for LogicalUnionAll.
	OperandUnionAll
	// OperandSort for LogicalSort.
	OperandSort
	// OperandTopN for LogicalTopN.
	OperandTopN
	// OperandLock for LogicalLock.
	OperandLock
	// OperandLimit for LogicalLimit.
	OperandLimit
	// OperandUnsupported is upper bound of defined Operand yet.
	OperandUnsupported
)

func GetOperand

func GetOperand(p plannercore.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.

type Pattern

type Pattern struct {
	Operand
	Children []*Pattern
}

Pattern defines the Match pattern for a rule. It describes a piece of logical expression. It's a tree-like structure and each node in the tree is an Operand.

func BuildPattern

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

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

func NewPattern

func NewPattern(operand Operand) *Pattern

NewPattern creats a pattern node according to the Operand.

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