memo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoDistinctOp distinctOp
	SortedDistinctOp
	HashDistinctOp
)

Variables

View Source
var ErrUnsupportedReorderNode = errors.New("unsupported join reorder node")
View Source
var HaltErr = errors.New("halt dfs")

Functions

func CardMemoGroups

func CardMemoGroups(g *ExprGroup)

func DescribeStats

func DescribeStats(r RelExpr) *sql.DescribeStats

func DfsRel

func DfsRel(grp *ExprGroup, cb func(rel RelExpr) error) error

DfsRel runs a callback |cb| on all execution plans in the memo expression group. An expression group is defined by 1) a set of child expression groups that serve as logical inputs to this operator, and 2) a set of logically equivalent plans for executing this expression group's operator. We recursively walk to expression group leaves, and then traverse every execution plan in leaf groups before working upwards back to the root group. Returning a HaltErr short circuits the walk.

func FormatExpr

func FormatExpr(r exprType) string

func NewJoinOrderBuilder

func NewJoinOrderBuilder(memo *Memo) *joinOrderBuilder

func TableIdForSource

func TableIdForSource(id GroupId) sql.TableId

Types

type AntiJoin

type AntiJoin struct {
	*JoinBase
}

func (AntiJoin) Cost

func (r AntiJoin) Cost() float64

func (AntiJoin) Distinct

func (r AntiJoin) Distinct() distinctOp

func (AntiJoin) Group

func (r AntiJoin) Group() *ExprGroup

func (*AntiJoin) JoinPrivate

func (r *AntiJoin) JoinPrivate() *JoinBase

func (AntiJoin) Next

func (r AntiJoin) Next() RelExpr

func (AntiJoin) SetCost

func (r AntiJoin) SetCost(c float64)

func (AntiJoin) SetDistinct

func (r AntiJoin) SetDistinct(d distinctOp)

func (AntiJoin) SetGroup

func (r AntiJoin) SetGroup(g *ExprGroup)

func (AntiJoin) SetNext

func (r AntiJoin) SetNext(rel RelExpr)

func (*AntiJoin) String

func (r *AntiJoin) String() string

type ArithType

type ArithType uint8
const (
	ArithTypeUnknown    ArithType = iota // unknown
	ArithTypeBitAnd                      // &
	ArithTypeBitOr                       // |
	ArithTypeBitXor                      // ^
	ArithTypePlus                        // +
	ArithTypeMinus                       // -
	ArithTypeMult                        // *
	ArithTypeDiv                         // /
	ArithTypeIntDiv                      // div
	ArithTypeMod                         // %
	ArithTypeShiftLeft                   // <<
	ArithTypeShiftRight                  // >>
)

func (ArithType) String

func (i ArithType) String() string

type ConcatJoin

type ConcatJoin struct {
	*JoinBase
	Concat []*IndexScan
}

func (ConcatJoin) Cost

func (r ConcatJoin) Cost() float64

func (ConcatJoin) Distinct

func (r ConcatJoin) Distinct() distinctOp

func (ConcatJoin) Group

func (r ConcatJoin) Group() *ExprGroup

func (*ConcatJoin) JoinPrivate

func (r *ConcatJoin) JoinPrivate() *JoinBase

func (ConcatJoin) Next

func (r ConcatJoin) Next() RelExpr

func (ConcatJoin) SetCost

func (r ConcatJoin) SetCost(c float64)

func (ConcatJoin) SetDistinct

func (r ConcatJoin) SetDistinct(d distinctOp)

func (ConcatJoin) SetGroup

func (r ConcatJoin) SetGroup(g *ExprGroup)

func (ConcatJoin) SetNext

func (r ConcatJoin) SetNext(rel RelExpr)

func (*ConcatJoin) String

func (r *ConcatJoin) String() string

type Coster

type Coster interface {
	// EstimateCost cost returns the incremental CPU and memory cost for an
	// operator, or an error. Cost is dependent on physical operator type,
	// and the cardinality of inputs.
	EstimateCost(*sql.Context, RelExpr, sql.StatsProvider) (float64, error)
}

Coster types can estimate the CPU and memory cost of physical execution operators.

func NewDefaultCoster

func NewDefaultCoster() Coster

func NewHashBiasedCoster

func NewHashBiasedCoster() Coster

func NewInnerBiasedCoster

func NewInnerBiasedCoster() Coster

func NewLookupBiasedCoster

func NewLookupBiasedCoster() Coster

func NewMergeBiasedCoster

func NewMergeBiasedCoster() Coster

func NewPartialBiasedCoster

func NewPartialBiasedCoster() Coster

func NewRangeHeapBiasedCoster

func NewRangeHeapBiasedCoster() Coster

type CrossJoin

type CrossJoin struct {
	*JoinBase
}

func (CrossJoin) Cost

func (r CrossJoin) Cost() float64

func (CrossJoin) Distinct

func (r CrossJoin) Distinct() distinctOp

func (CrossJoin) Group

func (r CrossJoin) Group() *ExprGroup

func (*CrossJoin) JoinPrivate

func (r *CrossJoin) JoinPrivate() *JoinBase

func (CrossJoin) Next

func (r CrossJoin) Next() RelExpr

func (CrossJoin) SetCost

func (r CrossJoin) SetCost(c float64)

func (CrossJoin) SetDistinct

func (r CrossJoin) SetDistinct(d distinctOp)

func (CrossJoin) SetGroup

func (r CrossJoin) SetGroup(g *ExprGroup)

func (CrossJoin) SetNext

func (r CrossJoin) SetNext(rel RelExpr)

func (*CrossJoin) String

func (r *CrossJoin) String() string

type Distinct

type Distinct struct {
	Child *ExprGroup
	// contains filtered or unexported fields
}

func (*Distinct) Children

func (r *Distinct) Children() []*ExprGroup

func (Distinct) Cost

func (r Distinct) Cost() float64

func (Distinct) Distinct

func (r Distinct) Distinct() distinctOp

func (Distinct) Group

func (r Distinct) Group() *ExprGroup

func (Distinct) Next

func (r Distinct) Next() RelExpr

func (Distinct) SetCost

func (r Distinct) SetCost(c float64)

func (Distinct) SetDistinct

func (r Distinct) SetDistinct(d distinctOp)

func (Distinct) SetGroup

func (r Distinct) SetGroup(g *ExprGroup)

func (Distinct) SetNext

func (r Distinct) SetNext(rel RelExpr)

func (*Distinct) String

func (r *Distinct) String() string

type EmptyTable

type EmptyTable struct {
	Table *plan.EmptyTable
	// contains filtered or unexported fields
}

func (*EmptyTable) Children

func (r *EmptyTable) Children() []*ExprGroup

func (EmptyTable) Indexes

func (s EmptyTable) Indexes() []*Index

func (*EmptyTable) Name

func (r *EmptyTable) Name() string

func (*EmptyTable) OutputCols

func (r *EmptyTable) OutputCols() sql.Schema

func (EmptyTable) SetIndexes

func (s EmptyTable) SetIndexes(indexes []*Index)

func (*EmptyTable) String

func (r *EmptyTable) String() string

func (*EmptyTable) TableId

func (r *EmptyTable) TableId() sql.TableId

func (*EmptyTable) TableIdNode

func (r *EmptyTable) TableIdNode() plan.TableIdNode

type ExecBuilder

type ExecBuilder struct{}

func NewExecBuilder

func NewExecBuilder() *ExecBuilder

type ExprGroup

type ExprGroup struct {
	RelProps *relProps
	First    RelExpr
	Best     RelExpr

	Id GroupId

	Cost   float64
	Done   bool
	HintOk bool
	// contains filtered or unexported fields
}

ExprGroup is a linked list of plans that return the same result set defined by row count and schema.

func (*ExprGroup) Prepend

func (e *ExprGroup) Prepend(rel RelExpr)

Prepend adds a new plan to an expression group at the beginning of the list, to avoid recursive exploration steps (like adding indexed joins).

func (*ExprGroup) String

func (e *ExprGroup) String() string

type Filter

type Filter struct {
	Child   *ExprGroup
	Filters []sql.Expression
	// contains filtered or unexported fields
}

func (*Filter) Children

func (r *Filter) Children() []*ExprGroup

func (Filter) Cost

func (r Filter) Cost() float64

func (Filter) Distinct

func (r Filter) Distinct() distinctOp

func (Filter) Group

func (r Filter) Group() *ExprGroup

func (Filter) Next

func (r Filter) Next() RelExpr

func (Filter) SetCost

func (r Filter) SetCost(c float64)

func (Filter) SetDistinct

func (r Filter) SetDistinct(d distinctOp)

func (Filter) SetGroup

func (r Filter) SetGroup(g *ExprGroup)

func (Filter) SetNext

func (r Filter) SetNext(rel RelExpr)

func (*Filter) String

func (r *Filter) String() string

type FullOuterJoin

type FullOuterJoin struct {
	*JoinBase
}

func (FullOuterJoin) Cost

func (r FullOuterJoin) Cost() float64

func (FullOuterJoin) Distinct

func (r FullOuterJoin) Distinct() distinctOp

func (FullOuterJoin) Group

func (r FullOuterJoin) Group() *ExprGroup

func (*FullOuterJoin) JoinPrivate

func (r *FullOuterJoin) JoinPrivate() *JoinBase

func (FullOuterJoin) Next

func (r FullOuterJoin) Next() RelExpr

func (FullOuterJoin) SetCost

func (r FullOuterJoin) SetCost(c float64)

func (FullOuterJoin) SetDistinct

func (r FullOuterJoin) SetDistinct(d distinctOp)

func (FullOuterJoin) SetGroup

func (r FullOuterJoin) SetGroup(g *ExprGroup)

func (FullOuterJoin) SetNext

func (r FullOuterJoin) SetNext(rel RelExpr)

func (*FullOuterJoin) String

func (r *FullOuterJoin) String() string

type GroupId

type GroupId uint16

type HashJoin

type HashJoin struct {
	*JoinBase
	RightAttrs []sql.Expression
	LeftAttrs  []sql.Expression
}

func (HashJoin) Cost

func (r HashJoin) Cost() float64

func (HashJoin) Distinct

func (r HashJoin) Distinct() distinctOp

func (HashJoin) Group

func (r HashJoin) Group() *ExprGroup

func (*HashJoin) JoinPrivate

func (r *HashJoin) JoinPrivate() *JoinBase

func (HashJoin) Next

func (r HashJoin) Next() RelExpr

func (HashJoin) SetCost

func (r HashJoin) SetCost(c float64)

func (HashJoin) SetDistinct

func (r HashJoin) SetDistinct(d distinctOp)

func (HashJoin) SetGroup

func (r HashJoin) SetGroup(g *ExprGroup)

func (HashJoin) SetNext

func (r HashJoin) SetNext(rel RelExpr)

func (*HashJoin) String

func (r *HashJoin) String() string

type Hint

type Hint struct {
	Typ  HintType
	Args []string
}

func ExtractJoinHint

func ExtractJoinHint(n *plan.JoinNode) []Hint

func (Hint) String

func (h Hint) String() string

type HintType

type HintType uint8
const (
	HintTypeUnknown                  HintType = iota //
	HintTypeJoinOrder                                // JOIN_ORDER
	HintTypeJoinFixedOrder                           // JOIN_FIXED_ORDER
	HintTypeMergeJoin                                // MERGE_JOIN
	HintTypeLookupJoin                               // LOOKUP_JOIN
	HintTypeHashJoin                                 // HASH_JOIN
	HintTypeSemiJoin                                 // SEMI_JOIN
	HintTypeAntiJoin                                 // ANTI_JOIN
	HintTypeInnerJoin                                // INNER_JOIN
	HintTypeLeftOuterLookupJoin                      // LEFT_OUTER_LOOKUP_JOIN
	HintTypeNoIndexConditionPushDown                 // NO_ICP
	HintTypeLeftDeep                                 // LEFT_DEEP
)

TODO implement NO_ICP and JOIN_FIXED_ORDER

func (HintType) String

func (i HintType) String() string

type Index

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

func (*Index) ColSet

func (i *Index) ColSet() sql.ColSet

func (*Index) Cols

func (i *Index) Cols() []sql.ColumnId

func (*Index) SqlIdx

func (i *Index) SqlIdx() sql.Index

type IndexScan

type IndexScan struct {
	Table *plan.IndexedTableAccess
	Index *Index
	Alias string
	Stats sql.Statistic
	// contains filtered or unexported fields
}

func (*IndexScan) Children

func (r *IndexScan) Children() []*ExprGroup

func (IndexScan) Indexes

func (s IndexScan) Indexes() []*Index

func (*IndexScan) Name

func (r *IndexScan) Name() string

func (*IndexScan) OutputCols

func (r *IndexScan) OutputCols() sql.Schema

func (IndexScan) SetIndexes

func (s IndexScan) SetIndexes(indexes []*Index)

func (*IndexScan) String

func (r *IndexScan) String() string

func (*IndexScan) TableId

func (r *IndexScan) TableId() sql.TableId

func (*IndexScan) TableIdNode

func (r *IndexScan) TableIdNode() plan.TableIdNode

type InnerJoin

type InnerJoin struct {
	*JoinBase
}

func (InnerJoin) Cost

func (r InnerJoin) Cost() float64

func (InnerJoin) Distinct

func (r InnerJoin) Distinct() distinctOp

func (InnerJoin) Group

func (r InnerJoin) Group() *ExprGroup

func (*InnerJoin) JoinPrivate

func (r *InnerJoin) JoinPrivate() *JoinBase

func (InnerJoin) Next

func (r InnerJoin) Next() RelExpr

func (InnerJoin) SetCost

func (r InnerJoin) SetCost(c float64)

func (InnerJoin) SetDistinct

func (r InnerJoin) SetDistinct(d distinctOp)

func (InnerJoin) SetGroup

func (r InnerJoin) SetGroup(g *ExprGroup)

func (InnerJoin) SetNext

func (r InnerJoin) SetNext(rel RelExpr)

func (*InnerJoin) String

func (r *InnerJoin) String() string

type JSONTable

type JSONTable struct {
	Table *plan.JSONTable
	// contains filtered or unexported fields
}

func (*JSONTable) Children

func (r *JSONTable) Children() []*ExprGroup

func (JSONTable) Indexes

func (s JSONTable) Indexes() []*Index

func (*JSONTable) Name

func (r *JSONTable) Name() string

func (*JSONTable) OutputCols

func (r *JSONTable) OutputCols() sql.Schema

func (JSONTable) SetIndexes

func (s JSONTable) SetIndexes(indexes []*Index)

func (*JSONTable) String

func (r *JSONTable) String() string

func (*JSONTable) TableId

func (r *JSONTable) TableId() sql.TableId

func (*JSONTable) TableIdNode

func (r *JSONTable) TableIdNode() plan.TableIdNode

type JoinBase

type JoinBase struct {
	Op     plan.JoinType
	Filter []sql.Expression
	Left   *ExprGroup
	Right  *ExprGroup
	// contains filtered or unexported fields
}

func (*JoinBase) Children

func (r *JoinBase) Children() []*ExprGroup

func (*JoinBase) Copy

func (r *JoinBase) Copy() *JoinBase

Copy creates a JoinBase with the same underlying join expression. note: it is important to Copy the base node to avoid cyclical relExpr references in the ExprGroup linked list.

func (JoinBase) Cost

func (r JoinBase) Cost() float64

func (JoinBase) Distinct

func (r JoinBase) Distinct() distinctOp

func (JoinBase) Group

func (r JoinBase) Group() *ExprGroup

func (*JoinBase) JoinPrivate

func (r *JoinBase) JoinPrivate() *JoinBase

func (JoinBase) Next

func (r JoinBase) Next() RelExpr

func (JoinBase) SetCost

func (r JoinBase) SetCost(c float64)

func (JoinBase) SetDistinct

func (r JoinBase) SetDistinct(d distinctOp)

func (JoinBase) SetGroup

func (r JoinBase) SetGroup(g *ExprGroup)

func (JoinBase) SetNext

func (r JoinBase) SetNext(rel RelExpr)

type JoinRel

type JoinRel interface {
	RelExpr
	JoinPrivate() *JoinBase
	Group() *ExprGroup
}

JoinRel represents a plan.JoinNode or plan.CrossJoin. See plan.JoinType for the full list.

type LateralJoin

type LateralJoin struct {
	*JoinBase
}

func (LateralJoin) Cost

func (r LateralJoin) Cost() float64

func (LateralJoin) Distinct

func (r LateralJoin) Distinct() distinctOp

func (LateralJoin) Group

func (r LateralJoin) Group() *ExprGroup

func (*LateralJoin) JoinPrivate

func (r *LateralJoin) JoinPrivate() *JoinBase

func (LateralJoin) Next

func (r LateralJoin) Next() RelExpr

func (LateralJoin) SetCost

func (r LateralJoin) SetCost(c float64)

func (LateralJoin) SetDistinct

func (r LateralJoin) SetDistinct(d distinctOp)

func (LateralJoin) SetGroup

func (r LateralJoin) SetGroup(g *ExprGroup)

func (LateralJoin) SetNext

func (r LateralJoin) SetNext(rel RelExpr)

func (*LateralJoin) String

func (r *LateralJoin) String() string

type LeftJoin

type LeftJoin struct {
	*JoinBase
}

func (LeftJoin) Cost

func (r LeftJoin) Cost() float64

func (LeftJoin) Distinct

func (r LeftJoin) Distinct() distinctOp

func (LeftJoin) Group

func (r LeftJoin) Group() *ExprGroup

func (*LeftJoin) JoinPrivate

func (r *LeftJoin) JoinPrivate() *JoinBase

func (LeftJoin) Next

func (r LeftJoin) Next() RelExpr

func (LeftJoin) SetCost

func (r LeftJoin) SetCost(c float64)

func (LeftJoin) SetDistinct

func (r LeftJoin) SetDistinct(d distinctOp)

func (LeftJoin) SetGroup

func (r LeftJoin) SetGroup(g *ExprGroup)

func (LeftJoin) SetNext

func (r LeftJoin) SetNext(rel RelExpr)

func (*LeftJoin) String

func (r *LeftJoin) String() string

type LookupJoin

type LookupJoin struct {
	*JoinBase
	Lookup    *IndexScan
	Injective bool
}

func (*LookupJoin) Children

func (r *LookupJoin) Children() []*ExprGroup

func (LookupJoin) Cost

func (r LookupJoin) Cost() float64

func (LookupJoin) Distinct

func (r LookupJoin) Distinct() distinctOp

func (LookupJoin) Group

func (r LookupJoin) Group() *ExprGroup

func (*LookupJoin) JoinPrivate

func (r *LookupJoin) JoinPrivate() *JoinBase

func (LookupJoin) Next

func (r LookupJoin) Next() RelExpr

func (LookupJoin) SetCost

func (r LookupJoin) SetCost(c float64)

func (LookupJoin) SetDistinct

func (r LookupJoin) SetDistinct(d distinctOp)

func (LookupJoin) SetGroup

func (r LookupJoin) SetGroup(g *ExprGroup)

func (LookupJoin) SetNext

func (r LookupJoin) SetNext(rel RelExpr)

func (*LookupJoin) String

func (r *LookupJoin) String() string

type Max1Row

type Max1Row struct {
	Child *ExprGroup
	// contains filtered or unexported fields
}

func (*Max1Row) Children

func (r *Max1Row) Children() []*ExprGroup

func (Max1Row) Cost

func (r Max1Row) Cost() float64

func (Max1Row) Distinct

func (r Max1Row) Distinct() distinctOp

func (Max1Row) Group

func (r Max1Row) Group() *ExprGroup

func (Max1Row) Next

func (r Max1Row) Next() RelExpr

func (Max1Row) SetCost

func (r Max1Row) SetCost(c float64)

func (Max1Row) SetDistinct

func (r Max1Row) SetDistinct(d distinctOp)

func (Max1Row) SetGroup

func (r Max1Row) SetGroup(g *ExprGroup)

func (Max1Row) SetNext

func (r Max1Row) SetNext(rel RelExpr)

func (*Max1Row) String

func (r *Max1Row) String() string

type Memo

type Memo struct {
	Ctx *sql.Context

	TableProps *tableProps
	// contains filtered or unexported fields
}

Memo collects a forest of query plans structured by logical and physical equivalency. Logically equivalent plans, represented by an exprGroup, produce the same rows (possibly unordered) and schema. Physical plans are stored in a linked list within an expression group.

func NewMemo

func NewMemo(ctx *sql.Context, stats sql.StatsProvider, s *plan.Scope, scopeLen int, cost Coster) *Memo

func (*Memo) ApplyHint

func (m *Memo) ApplyHint(hint Hint)

func (*Memo) BestRootPlan

func (m *Memo) BestRootPlan(ctx *sql.Context) (sql.Node, error)

func (*Memo) HandleErr

func (m *Memo) HandleErr(err error)

func (*Memo) MemoizeConcatLookupJoin

func (m *Memo) MemoizeConcatLookupJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression, lookups []*IndexScan) *ExprGroup

MemoizeConcatLookupJoin creates a lookup join over a set of disjunctions. If a LOOKUP_JOIN simulates x = v1, a concat lookup performs x in (v1, v2, v3, ...)

func (*Memo) MemoizeFilter

func (m *Memo) MemoizeFilter(grp, child *ExprGroup, filters []sql.Expression) *ExprGroup

func (*Memo) MemoizeHashJoin

func (m *Memo) MemoizeHashJoin(grp *ExprGroup, join *JoinBase, toExpr, fromExpr []sql.Expression) *ExprGroup

func (*Memo) MemoizeIndexScan

func (m *Memo) MemoizeIndexScan(grp *ExprGroup, ita *plan.IndexedTableAccess, alias string, index *Index, stat sql.Statistic) *ExprGroup

MemoizeIndexScan creates a source node that uses a specific index to access data. IndexScans are either static and read a specific set of ranges, or dynamic and use a lookup template that is iteratively bound and executed during LOOKUP_JOINs.

func (*Memo) MemoizeInnerJoin

func (m *Memo) MemoizeInnerJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression) *ExprGroup

func (*Memo) MemoizeLeftJoin

func (m *Memo) MemoizeLeftJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression) *ExprGroup

func (*Memo) MemoizeLookupJoin

func (m *Memo) MemoizeLookupJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression, lookup *IndexScan) *ExprGroup

func (*Memo) MemoizeMax1Row

func (m *Memo) MemoizeMax1Row(grp, child *ExprGroup) *ExprGroup

func (*Memo) MemoizeMergeJoin

func (m *Memo) MemoizeMergeJoin(grp, left, right *ExprGroup, lIdx, rIdx *IndexScan, op plan.JoinType, filter []sql.Expression, swapCmp bool) *ExprGroup

func (*Memo) MemoizeProject

func (m *Memo) MemoizeProject(grp, child *ExprGroup, projections []sql.Expression) *ExprGroup

func (*Memo) MemoizeRangeHeapJoin

func (m *Memo) MemoizeRangeHeapJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression, rangeHeap *RangeHeap) *ExprGroup

func (*Memo) NewExprGroup

func (m *Memo) NewExprGroup(rel exprType) *ExprGroup

newExprGroup creates a new logical expression group to encapsulate the action of a SQL clause. TODO: this is supposed to deduplicate logically equivalent table scans and scalar expressions, replacing references with a pointer. Currently a hacky format to quickly support memoizing join trees.

func (*Memo) OptimizeRoot

func (m *Memo) OptimizeRoot() error

OptimizeRoot finds the implementation for the root expression that has the lowest cost.

func (*Memo) Root

func (m *Memo) Root() *ExprGroup

func (*Memo) StatsProvider

func (m *Memo) StatsProvider() sql.StatsProvider

func (*Memo) String

func (m *Memo) String() string

func (*Memo) WithJoinOp

func (m *Memo) WithJoinOp(op HintType, left, right string)

func (*Memo) WithJoinOrder

func (m *Memo) WithJoinOrder(tables []string)

type MemoErr

type MemoErr struct {
	Err error
}

type MergeJoin

type MergeJoin struct {
	*JoinBase
	InnerScan *IndexScan
	OuterScan *IndexScan
	SwapCmp   bool
	Injective bool
	CmpCnt    int
}

func (MergeJoin) Cost

func (r MergeJoin) Cost() float64

func (MergeJoin) Distinct

func (r MergeJoin) Distinct() distinctOp

func (MergeJoin) Group

func (r MergeJoin) Group() *ExprGroup

func (*MergeJoin) JoinPrivate

func (r *MergeJoin) JoinPrivate() *JoinBase

func (MergeJoin) Next

func (r MergeJoin) Next() RelExpr

func (MergeJoin) SetCost

func (r MergeJoin) SetCost(c float64)

func (MergeJoin) SetDistinct

func (r MergeJoin) SetDistinct(d distinctOp)

func (MergeJoin) SetGroup

func (r MergeJoin) SetGroup(g *ExprGroup)

func (MergeJoin) SetNext

func (r MergeJoin) SetNext(rel RelExpr)

func (*MergeJoin) String

func (r *MergeJoin) String() string

type Project

type Project struct {
	Child       *ExprGroup
	Projections []sql.Expression
	// contains filtered or unexported fields
}

func (*Project) Children

func (r *Project) Children() []*ExprGroup

func (Project) Cost

func (r Project) Cost() float64

func (Project) Distinct

func (r Project) Distinct() distinctOp

func (Project) Group

func (r Project) Group() *ExprGroup

func (Project) Next

func (r Project) Next() RelExpr

func (Project) SetCost

func (r Project) SetCost(c float64)

func (Project) SetDistinct

func (r Project) SetDistinct(d distinctOp)

func (Project) SetGroup

func (r Project) SetGroup(g *ExprGroup)

func (Project) SetNext

func (r Project) SetNext(rel RelExpr)

func (*Project) String

func (r *Project) String() string

type RangeHeap

type RangeHeap struct {
	ValueIndex *IndexScan
	ValueExpr  sql.Expression

	MinIndex *IndexScan
	MinExpr  sql.Expression

	ValueCol                *expression.GetField
	MinColRef               *expression.GetField
	MaxColRef               *expression.GetField
	RangeClosedOnLowerBound bool
	RangeClosedOnUpperBound bool
	Parent                  *JoinBase
}

RangeHeap contains all the information necessary to construct a RangeHeap join. Because both sides of the join can be implemented either by an index or a sorted node, we require that exactly one of ValueIndex and ValueExpr is non-nil, and exactly one of MinIndex and MinExpr is non-nil. If the index is non-nil, we will use it to construct a plan.IndexedTableAccess. Otherwise we use the expression to construct a plan.Sort.

type RangeHeapJoin

type RangeHeapJoin struct {
	*JoinBase
	RangeHeap *RangeHeap
}

func (RangeHeapJoin) Cost

func (r RangeHeapJoin) Cost() float64

func (RangeHeapJoin) Distinct

func (r RangeHeapJoin) Distinct() distinctOp

func (RangeHeapJoin) Group

func (r RangeHeapJoin) Group() *ExprGroup

func (*RangeHeapJoin) JoinPrivate

func (r *RangeHeapJoin) JoinPrivate() *JoinBase

func (RangeHeapJoin) Next

func (r RangeHeapJoin) Next() RelExpr

func (RangeHeapJoin) SetCost

func (r RangeHeapJoin) SetCost(c float64)

func (RangeHeapJoin) SetDistinct

func (r RangeHeapJoin) SetDistinct(d distinctOp)

func (RangeHeapJoin) SetGroup

func (r RangeHeapJoin) SetGroup(g *ExprGroup)

func (RangeHeapJoin) SetNext

func (r RangeHeapJoin) SetNext(rel RelExpr)

func (*RangeHeapJoin) String

func (r *RangeHeapJoin) String() string

type RecursiveCte

type RecursiveCte struct {
	Table *plan.RecursiveCte
	// contains filtered or unexported fields
}

func (*RecursiveCte) Children

func (r *RecursiveCte) Children() []*ExprGroup

func (RecursiveCte) Indexes

func (s RecursiveCte) Indexes() []*Index

func (*RecursiveCte) Name

func (r *RecursiveCte) Name() string

func (*RecursiveCte) OutputCols

func (r *RecursiveCte) OutputCols() sql.Schema

func (RecursiveCte) SetIndexes

func (s RecursiveCte) SetIndexes(indexes []*Index)

func (*RecursiveCte) String

func (r *RecursiveCte) String() string

func (*RecursiveCte) TableId

func (r *RecursiveCte) TableId() sql.TableId

func (*RecursiveCte) TableIdNode

func (r *RecursiveCte) TableIdNode() plan.TableIdNode

type RecursiveTable

type RecursiveTable struct {
	Table *plan.RecursiveTable
	// contains filtered or unexported fields
}

func (*RecursiveTable) Children

func (r *RecursiveTable) Children() []*ExprGroup

func (RecursiveTable) Indexes

func (s RecursiveTable) Indexes() []*Index

func (*RecursiveTable) Name

func (r *RecursiveTable) Name() string

func (*RecursiveTable) OutputCols

func (r *RecursiveTable) OutputCols() sql.Schema

func (RecursiveTable) SetIndexes

func (s RecursiveTable) SetIndexes(indexes []*Index)

func (*RecursiveTable) String

func (r *RecursiveTable) String() string

func (*RecursiveTable) TableId

func (r *RecursiveTable) TableId() sql.TableId

func (*RecursiveTable) TableIdNode

func (r *RecursiveTable) TableIdNode() plan.TableIdNode

type RelExpr

type RelExpr interface {
	fmt.Stringer

	Next() RelExpr
	SetNext(RelExpr)
	SetCost(c float64)
	Cost() float64
	Distinct() distinctOp
	SetDistinct(distinctOp)
	// contains filtered or unexported methods
}

RelExpr wraps a sql.Node for use as a ExprGroup linked list node. TODO: we need relExprs for every sql.Node and sql.Expression

type SemiJoin

type SemiJoin struct {
	*JoinBase
}

func (SemiJoin) Cost

func (r SemiJoin) Cost() float64

func (SemiJoin) Distinct

func (r SemiJoin) Distinct() distinctOp

func (SemiJoin) Group

func (r SemiJoin) Group() *ExprGroup

func (*SemiJoin) JoinPrivate

func (r *SemiJoin) JoinPrivate() *JoinBase

func (SemiJoin) Next

func (r SemiJoin) Next() RelExpr

func (SemiJoin) SetCost

func (r SemiJoin) SetCost(c float64)

func (SemiJoin) SetDistinct

func (r SemiJoin) SetDistinct(d distinctOp)

func (SemiJoin) SetGroup

func (r SemiJoin) SetGroup(g *ExprGroup)

func (SemiJoin) SetNext

func (r SemiJoin) SetNext(rel RelExpr)

func (*SemiJoin) String

func (r *SemiJoin) String() string

type SetOp

type SetOp struct {
	Table *plan.SetOp
	// contains filtered or unexported fields
}

func (*SetOp) Children

func (r *SetOp) Children() []*ExprGroup

func (SetOp) Indexes

func (s SetOp) Indexes() []*Index

func (*SetOp) Name

func (r *SetOp) Name() string

func (*SetOp) OutputCols

func (r *SetOp) OutputCols() sql.Schema

func (SetOp) SetIndexes

func (s SetOp) SetIndexes(indexes []*Index)

func (*SetOp) String

func (r *SetOp) String() string

func (*SetOp) TableId

func (r *SetOp) TableId() sql.TableId

func (*SetOp) TableIdNode

func (r *SetOp) TableIdNode() plan.TableIdNode

type SourceRel

type SourceRel interface {
	RelExpr
	// outputCols retuns the output schema of this data source.
	// TODO: this is more useful as a relExpr property, but we need
	// this to fix up expression indexes currently
	OutputCols() sql.Schema
	Name() string
	TableId() sql.TableId
	Indexes() []*Index
	SetIndexes(indexes []*Index)
	TableIdNode() plan.TableIdNode
}

SourceRel represents a data source, like a tableScan, subqueryAlias, or list of values.

type SubqueryAlias

type SubqueryAlias struct {
	Table *plan.SubqueryAlias
	// contains filtered or unexported fields
}

func (*SubqueryAlias) Children

func (r *SubqueryAlias) Children() []*ExprGroup

func (SubqueryAlias) Indexes

func (s SubqueryAlias) Indexes() []*Index

func (*SubqueryAlias) Name

func (r *SubqueryAlias) Name() string

func (*SubqueryAlias) OutputCols

func (r *SubqueryAlias) OutputCols() sql.Schema

func (SubqueryAlias) SetIndexes

func (s SubqueryAlias) SetIndexes(indexes []*Index)

func (*SubqueryAlias) String

func (r *SubqueryAlias) String() string

func (*SubqueryAlias) TableId

func (r *SubqueryAlias) TableId() sql.TableId

func (*SubqueryAlias) TableIdNode

func (r *SubqueryAlias) TableIdNode() plan.TableIdNode

type TableAlias

type TableAlias struct {
	Table *plan.TableAlias
	// contains filtered or unexported fields
}

func (*TableAlias) Children

func (r *TableAlias) Children() []*ExprGroup

func (TableAlias) Indexes

func (s TableAlias) Indexes() []*Index

func (*TableAlias) Name

func (r *TableAlias) Name() string

func (*TableAlias) OutputCols

func (r *TableAlias) OutputCols() sql.Schema

func (TableAlias) SetIndexes

func (s TableAlias) SetIndexes(indexes []*Index)

func (*TableAlias) String

func (r *TableAlias) String() string

func (*TableAlias) TableId

func (r *TableAlias) TableId() sql.TableId

func (*TableAlias) TableIdNode

func (r *TableAlias) TableIdNode() plan.TableIdNode

type TableAndColumn

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

type TableFunc

type TableFunc struct {
	Table sql.TableFunction
	// contains filtered or unexported fields
}

func (*TableFunc) Children

func (r *TableFunc) Children() []*ExprGroup

func (TableFunc) Indexes

func (s TableFunc) Indexes() []*Index

func (*TableFunc) Name

func (r *TableFunc) Name() string

func (*TableFunc) OutputCols

func (r *TableFunc) OutputCols() sql.Schema

func (TableFunc) SetIndexes

func (s TableFunc) SetIndexes(indexes []*Index)

func (*TableFunc) String

func (r *TableFunc) String() string

func (*TableFunc) TableId

func (r *TableFunc) TableId() sql.TableId

func (*TableFunc) TableIdNode

func (r *TableFunc) TableIdNode() plan.TableIdNode

type TableId

type TableId uint16

type TableScan

type TableScan struct {
	Table plan.TableIdNode
	// contains filtered or unexported fields
}

func (*TableScan) Children

func (r *TableScan) Children() []*ExprGroup

func (TableScan) Indexes

func (s TableScan) Indexes() []*Index

func (*TableScan) Name

func (r *TableScan) Name() string

func (*TableScan) OutputCols

func (r *TableScan) OutputCols() sql.Schema

func (TableScan) SetIndexes

func (s TableScan) SetIndexes(indexes []*Index)

func (*TableScan) String

func (r *TableScan) String() string

func (*TableScan) TableId

func (r *TableScan) TableId() sql.TableId

func (*TableScan) TableIdNode

func (r *TableScan) TableIdNode() plan.TableIdNode

type Values

type Values struct {
	Table *plan.ValueDerivedTable
	// contains filtered or unexported fields
}

func (*Values) Children

func (r *Values) Children() []*ExprGroup

func (Values) Indexes

func (s Values) Indexes() []*Index

func (*Values) Name

func (r *Values) Name() string

func (*Values) OutputCols

func (r *Values) OutputCols() sql.Schema

func (Values) SetIndexes

func (s Values) SetIndexes(indexes []*Index)

func (*Values) String

func (r *Values) String() string

func (*Values) TableId

func (r *Values) TableId() sql.TableId

func (*Values) TableIdNode

func (r *Values) TableIdNode() plan.TableIdNode

Jump to

Keyboard shortcuts

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