planner

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggrType

type AggrType string

AggrType type.

const (
	// AggrTypeNull enum.
	AggrTypeNull AggrType = ""

	// AggrTypeCount enum.
	AggrTypeCount AggrType = "COUNT"

	// AggrTypeSum enum.
	AggrTypeSum AggrType = "SUM"

	// AggrTypeMin enum.
	AggrTypeMin AggrType = "MIN"

	// AggrTypeMax enum.
	AggrTypeMax AggrType = "MAX"

	// AggrTypeAvg enum.
	AggrTypeAvg AggrType = "AVG"

	// AggrTypeGroupBy enum.
	AggrTypeGroupBy AggrType = "GROUP BY"
)

type AggregatePlan

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

AggregatePlan represents order-by plan.

func NewAggregatePlan

func NewAggregatePlan(log *xlog.Log, node *sqlparser.Select, tuples []selectTuple) *AggregatePlan

NewAggregatePlan used to create AggregatePlan.

func (*AggregatePlan) Build

func (p *AggregatePlan) Build() error

Build used to build distributed querys.

func (*AggregatePlan) Children

func (p *AggregatePlan) Children() *PlanTree

Children returns the children of the plan.

func (*AggregatePlan) Empty

func (p *AggregatePlan) Empty() bool

Empty returns the aggregator number more than zero.

func (*AggregatePlan) GroupAggregators

func (p *AggregatePlan) GroupAggregators() []Aggregator

GroupAggregators returns the group aggregators.

func (*AggregatePlan) JSON

func (p *AggregatePlan) JSON() string

JSON returns the plan info.

func (*AggregatePlan) NormalAggregators

func (p *AggregatePlan) NormalAggregators() []Aggregator

NormalAggregators returns the aggregators.

func (*AggregatePlan) ReWritten

func (p *AggregatePlan) ReWritten() sqlparser.SelectExprs

ReWritten used to re-write the SelectExprs clause.

func (*AggregatePlan) Size

func (p *AggregatePlan) Size() int

Size returns the memory size.

func (*AggregatePlan) Type

func (p *AggregatePlan) Type() PlanType

Type returns the type of the plan.

type Aggregator

type Aggregator struct {
	Field string
	Index int
	Type  AggrType
}

Aggregator tuple.

type DDLPlan

type DDLPlan struct {

	// raw query
	RawQuery string

	// mode
	ReqMode xcontext.RequestMode

	// query and backend tuple
	Querys []xcontext.QueryTuple
	// contains filtered or unexported fields
}

DDLPlan represents a CREATE, ALTER, DROP or RENAME plan

func NewDDLPlan

func NewDDLPlan(log *xlog.Log, database string, query string, node *sqlparser.DDL, router *router.Router) *DDLPlan

NewDDLPlan used to create DDLPlan

func (*DDLPlan) Build

func (p *DDLPlan) Build() error

Build used to build DDL distributed querys. sqlparser.DDL is a simple grammar ast, it just parses database and table name in the prefix.

func (*DDLPlan) Children

func (p *DDLPlan) Children() *PlanTree

Children returns the children of the plan.

func (*DDLPlan) JSON

func (p *DDLPlan) JSON() string

JSON returns the plan info.

func (*DDLPlan) Size

func (p *DDLPlan) Size() int

Size returns the memory size.

func (*DDLPlan) Type

func (p *DDLPlan) Type() PlanType

Type returns the type of the plan.

type DeletePlan

type DeletePlan struct {

	// raw query
	RawQuery string

	// mode
	ReqMode xcontext.RequestMode

	// query and backend tuple
	Querys []xcontext.QueryTuple
	// contains filtered or unexported fields
}

DeletePlan represents delete plan

func NewDeletePlan

func NewDeletePlan(log *xlog.Log, database string, query string, node *sqlparser.Delete, router *router.Router) *DeletePlan

NewDeletePlan used to create DeletePlan

func (*DeletePlan) Build

func (p *DeletePlan) Build() error

Build used to build distributed querys.

func (*DeletePlan) Children

func (p *DeletePlan) Children() *PlanTree

Children returns the children of the plan.

func (*DeletePlan) JSON

func (p *DeletePlan) JSON() string

JSON returns the plan info.

func (*DeletePlan) Size

func (p *DeletePlan) Size() int

Size returns the memory size.

func (*DeletePlan) Type

func (p *DeletePlan) Type() PlanType

Type returns the type of the plan.

type Direction

type Direction string

Direction type.

const (
	// ASC enum.
	ASC Direction = "ASC"

	// DESC enum.
	DESC Direction = "DESC"
)

type DistinctPlan

type DistinctPlan struct {

	// type
	Typ PlanType
	// contains filtered or unexported fields
}

DistinctPlan represents distinct plan.

func NewDistinctPlan

func NewDistinctPlan(log *xlog.Log, node *sqlparser.Select) *DistinctPlan

NewDistinctPlan used to create DistinctPlan.

func (*DistinctPlan) Build

func (p *DistinctPlan) Build() error

Build used to build distributed querys.

func (*DistinctPlan) Children

func (p *DistinctPlan) Children() *PlanTree

Children returns the children of the plan.

func (*DistinctPlan) JSON

func (p *DistinctPlan) JSON() string

JSON returns the plan info.

func (*DistinctPlan) Size

func (p *DistinctPlan) Size() int

Size returns the memory size.

func (*DistinctPlan) Type

func (p *DistinctPlan) Type() PlanType

Type returns the type of the plan.

type InsertPlan

type InsertPlan struct {

	// raw query
	RawQuery string

	// type
	Typ PlanType

	// mode
	ReqMode xcontext.RequestMode

	// query and backend tuple
	Querys []xcontext.QueryTuple
	// contains filtered or unexported fields
}

InsertPlan represents insertion plan

func NewInsertPlan

func NewInsertPlan(log *xlog.Log, database string, query string, node *sqlparser.Insert, router *router.Router) *InsertPlan

NewInsertPlan used to create InsertPlan

func (*InsertPlan) Build

func (p *InsertPlan) Build() error

Build used to build distributed querys.

func (*InsertPlan) Children

func (p *InsertPlan) Children() *PlanTree

Children returns the children of the plan.

func (*InsertPlan) JSON

func (p *InsertPlan) JSON() string

JSON returns the plan info.

func (*InsertPlan) Size

func (p *InsertPlan) Size() int

Size returns the memory size.

func (*InsertPlan) Type

func (p *InsertPlan) Type() PlanType

Type returns the type of the plan.

type JoinPlan

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

JoinPlan represents join plan.

func NewJoinPlan

func NewJoinPlan(log *xlog.Log, node *sqlparser.Select) *JoinPlan

NewJoinPlan used to create JoinPlan.

func (*JoinPlan) Build

func (p *JoinPlan) Build() error

Build used to build distributed querys.

func (*JoinPlan) Children

func (p *JoinPlan) Children() *PlanTree

Children returns the children of the plan.

func (*JoinPlan) JSON

func (p *JoinPlan) JSON() string

JSON returns the plan info.

func (*JoinPlan) Size

func (p *JoinPlan) Size() int

Size returns the memory size.

func (*JoinPlan) Type

func (p *JoinPlan) Type() PlanType

Type returns the type of the plan.

type LimitPlan

type LimitPlan struct {
	Offset int
	Limit  int
	// contains filtered or unexported fields
}

LimitPlan represents order-by plan.

func NewLimitPlan

func NewLimitPlan(log *xlog.Log, node *sqlparser.Select) *LimitPlan

NewLimitPlan used to create LimitPlan.

func (*LimitPlan) Build

func (p *LimitPlan) Build() error

Build used to build distributed querys.

func (*LimitPlan) Children

func (p *LimitPlan) Children() *PlanTree

Children returns the children of the plan.

func (*LimitPlan) JSON

func (p *LimitPlan) JSON() string

JSON returns the plan info.

func (*LimitPlan) ReWritten

func (p *LimitPlan) ReWritten() *sqlparser.Limit

ReWritten used to re-write the limit clause.

func (*LimitPlan) Size

func (p *LimitPlan) Size() int

Size returns the memory size.

func (*LimitPlan) Type

func (p *LimitPlan) Type() PlanType

Type returns the type of the plan.

type OrderBy

type OrderBy struct {
	Field     string
	Direction Direction
}

OrderBy tuple.

type OrderByPlan

type OrderByPlan struct {
	OrderBys []OrderBy `json:"OrderBy(s)"`
	// contains filtered or unexported fields
}

OrderByPlan represents order-by plan.

func NewOrderByPlan

func NewOrderByPlan(log *xlog.Log, node *sqlparser.Select, tuples []selectTuple) *OrderByPlan

NewOrderByPlan used to create OrderByPlan.

func (*OrderByPlan) Build

func (p *OrderByPlan) Build() error

Build used to build distributed querys.

func (*OrderByPlan) Children

func (p *OrderByPlan) Children() *PlanTree

Children returns the children of the plan.

func (*OrderByPlan) JSON

func (p *OrderByPlan) JSON() string

JSON returns the plan info.

func (*OrderByPlan) Size

func (p *OrderByPlan) Size() int

Size returns the memory size.

func (*OrderByPlan) Type

func (p *OrderByPlan) Type() PlanType

Type returns the type of the plan.

type Plan

type Plan interface {
	Build() error
	Type() PlanType
	JSON() string
	Size() int
	Children() *PlanTree
}

Plan interface.

type PlanTree

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

PlanTree is a container for all plans

func NewPlanTree

func NewPlanTree() *PlanTree

NewPlanTree creates the new plan tree.

func (*PlanTree) Add

func (pt *PlanTree) Add(plan Plan) error

Add used to add new plan to the tree.

func (*PlanTree) Build

func (pt *PlanTree) Build() error

Build used to build plans(we won't build sub-plans in this plan).

func (*PlanTree) Plans

func (pt *PlanTree) Plans() []Plan

Plans returns all the plans of the tree.

func (*PlanTree) Size

func (pt *PlanTree) Size() int

Size used to measure the memory usage for this plantree.

type PlanType

type PlanType string

PlanType type.

const (
	// PlanTypeDDL enum.
	PlanTypeDDL PlanType = "PlanTypeDDL"

	// PlanTypeInsert enum.
	PlanTypeInsert PlanType = "PlanTypeInsert"

	// PlanTypeDelete enum.
	PlanTypeDelete PlanType = "PlanTypeDelete"

	// PlanTypeUpdate enum.
	PlanTypeUpdate PlanType = "PlanTypeUpdate"

	// PlanTypeSelect enum.
	PlanTypeSelect PlanType = "PlanTypeSelect"

	// PlanTypeOrderby enum.
	PlanTypeOrderby PlanType = "PlanTypeOrderby"

	// PlanTypeLimit enum.
	PlanTypeLimit PlanType = "PlanTypeLimit"

	// PlanTypeAggregate enum.
	PlanTypeAggregate PlanType = "PlanTypeAggregate"

	// PlanTypeJoin enum.
	PlanTypeJoin PlanType = "PlanTypeJoin"

	// PlanTypeDistinct enum.
	PlanTypeDistinct PlanType = "PlanTypeDistinct"
)

type SelectPlan

type SelectPlan struct {

	// raw query
	RawQuery string

	// mode
	ReqMode xcontext.RequestMode

	// query and backend tuple
	Querys []xcontext.QueryTuple
	// contains filtered or unexported fields
}

SelectPlan represents select plan

func NewSelectPlan

func NewSelectPlan(log *xlog.Log, database string, query string, node *sqlparser.Select, router *router.Router) *SelectPlan

NewSelectPlan used to create SelectPlan

func (*SelectPlan) Build

func (p *SelectPlan) Build() error

Build used to build distributed querys. For now, we don't support subquery in select.

func (*SelectPlan) Children

func (p *SelectPlan) Children() *PlanTree

Children returns the children of the plan.

func (*SelectPlan) JSON

func (p *SelectPlan) JSON() string

JSON returns the plan info.

func (*SelectPlan) Size

func (p *SelectPlan) Size() int

Size returns the memory size.

func (*SelectPlan) Type

func (p *SelectPlan) Type() PlanType

Type returns the type of the plan.

type UpdatePlan

type UpdatePlan struct {

	// raw query
	RawQuery string

	// mode
	ReqMode xcontext.RequestMode

	// query and backend tuple
	Querys []xcontext.QueryTuple
	// contains filtered or unexported fields
}

UpdatePlan represents delete plan

func NewUpdatePlan

func NewUpdatePlan(log *xlog.Log, database string, query string, node *sqlparser.Update, router *router.Router) *UpdatePlan

NewUpdatePlan used to create UpdatePlan

func (*UpdatePlan) Build

func (p *UpdatePlan) Build() error

Build used to build distributed querys.

func (*UpdatePlan) Children

func (p *UpdatePlan) Children() *PlanTree

Children returns the children of the plan.

func (*UpdatePlan) JSON

func (p *UpdatePlan) JSON() string

JSON returns the plan info.

func (*UpdatePlan) Size

func (p *UpdatePlan) Size() int

Size returns the memory size.

func (*UpdatePlan) Type

func (p *UpdatePlan) Type() PlanType

Type returns the type of the plan.

Jump to

Keyboard shortcuts

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