memo

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

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExploreMark

type ExploreMark int

ExploreMark is uses to mark whether a Group or GroupExpr has been fully explored by a transformation rule batch.

func (*ExploreMark) Explored

func (m *ExploreMark) Explored(round int) bool

Explored returns whether the roundth bit has been set.

func (*ExploreMark) SetExplored

func (m *ExploreMark) SetExplored(round int)

SetExplored sets the roundth bit.

func (*ExploreMark) SetUnexplored

func (m *ExploreMark) SetUnexplored(round int)

SetUnexplored unsets the roundth bit.

type ExprIter

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

	// Pattern describes the node of pattern tree.
	// The Operand type of the Group expression and the EngineType of the Group
	// must be matched with it.
	*pattern.Pattern

	// 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.Pattern) *ExprIter

NewExprIterFromGroupElem creates the iterator on the Group Element.

func (*ExprIter) GetExpr

func (iter *ExprIter) GetExpr() *GroupExpr

GetExpr returns the root GroupExpr of the iterator.

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[pattern.Operand]*list.Element
	Fingerprints map[string]*list.Element

	ImplMap map[string]Implementation
	Prop    *property.LogicalProperty

	EngineType pattern.EngineType

	SelfFingerprint string

	// ExploreMark is uses to mark whether this Group has been explored
	// by a transformation rule batch in a certain round.
	ExploreMark
	// contains filtered or unexported fields
}

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

func Convert2Group

func Convert2Group(node base.LogicalPlan) *Group

Convert2Group converts a logical plan to a Group.

func NewGroupWithSchema

func NewGroupWithSchema(e *GroupExpr, s *expression.Schema) *Group

NewGroupWithSchema creates a new Group with given schema.

func (*Group) BuildKeyInfo

func (g *Group) BuildKeyInfo()

BuildKeyInfo recursively builds UniqueKey and MaxOneRow info in the LogicalProperty.

func (*Group) Delete

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

Delete an existing Group expression.

func (*Group) DeleteAll

func (g *Group) DeleteAll()

DeleteAll deletes all of the GroupExprs in the Group.

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 pattern.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.

func (*Group) SetEngineType

func (g *Group) SetEngineType(e pattern.EngineType) *Group

SetEngineType sets the engine type of the group.

type GroupExpr

type GroupExpr struct {
	ExprNode base.LogicalPlan
	Children []*Group
	Group    *Group

	// ExploreMark is uses to mark whether this GroupExpr has been fully
	// explored by a transformation rule batch in a certain round.
	ExploreMark
	// 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 Convert2GroupExpr

func Convert2GroupExpr(node base.LogicalPlan) *GroupExpr

Convert2GroupExpr converts a logical plan to a GroupExpr.

func NewGroupExpr

func NewGroupExpr(node base.LogicalPlan) *GroupExpr

NewGroupExpr creates a GroupExpr based on a logical plan node.

func (*GroupExpr) AddAppliedRule

func (e *GroupExpr) AddAppliedRule(rule any)

AddAppliedRule adds a rule into the appliedRuleSet.

func (*GroupExpr) FingerPrint

func (e *GroupExpr) FingerPrint() string

FingerPrint gets the unique fingerprint of the Group expression.

func (*GroupExpr) HasAppliedRule

func (e *GroupExpr) HasAppliedRule(rule any) bool

HasAppliedRule returns if the rule has been applied.

func (*GroupExpr) Schema

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

Schema gets GroupExpr's Schema.

func (*GroupExpr) SetChildren

func (e *GroupExpr) SetChildren(children ...*Group)

SetChildren sets Children of the GroupExpr.

type Implementation

type Implementation interface {
	CalcCost(outCount float64, children ...Implementation) float64
	SetCost(cost float64)
	GetCost() float64
	GetPlan() plannercore.PhysicalPlan

	// AttachChildren is used to attach children implementations and returns it self.
	AttachChildren(children ...Implementation) Implementation

	// GetCostLimit gets the costLimit for implementing the next childGroup.
	GetCostLimit(costLimit float64, children ...Implementation) float64
}

Implementation defines the interface for cost of physical plan.

Jump to

Keyboard shortcuts

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