Documentation ¶
Index ¶
- type AggrType
- type AggregatePlan
- func (p *AggregatePlan) Build() error
- func (p *AggregatePlan) Children() *PlanTree
- func (p *AggregatePlan) Empty() bool
- func (p *AggregatePlan) GroupAggregators() []Aggregator
- func (p *AggregatePlan) JSON() string
- func (p *AggregatePlan) NormalAggregators() []Aggregator
- func (p *AggregatePlan) ReWritten() sqlparser.SelectExprs
- func (p *AggregatePlan) Size() int
- func (p *AggregatePlan) Type() PlanType
- type Aggregator
- type Comparison
- type DDLPlan
- type DeletePlan
- type Direction
- type InsertPlan
- type JoinKey
- type JoinNode
- type JoinStrategy
- type LimitPlan
- type MergeNode
- type OrderBy
- type OrderByPlan
- type OthersPlan
- type Plan
- type PlanNode
- type PlanTree
- type PlanType
- type SelectPlan
- type TableInfo
- type UpdatePlan
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 { // IsPushDown whether aggfunc can be pushed down. IsPushDown bool // contains filtered or unexported fields }
AggregatePlan represents order-by plan.
func NewAggregatePlan ¶
func NewAggregatePlan(log *xlog.Log, exprs []sqlparser.SelectExpr, tuples, groups []selectTuple, isPushDown bool) *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) 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) Type ¶
func (p *AggregatePlan) Type() PlanType
Type returns the type of the plan.
type Aggregator ¶
Aggregator tuple.
type Comparison ¶ added in v1.0.6
type Comparison struct { // index in left and right node's fields. Left, Right int Operator string // left expr may in right node. Exchange bool }
Comparison is record the sqlparser.Comparison info.
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 ¶
Build used to build DDL distributed querys. sqlparser.DDL is a simple grammar ast, it just parses database and table name in the prefix.
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.
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.
type JoinKey ¶ added in v1.0.6
type JoinKey struct { // field name. Field string // table name. Table string // index in the fields. Index int }
JoinKey is the column info in the on conditions.
type JoinNode ¶ added in v1.0.5
type JoinNode struct {
// Left and Right are the nodes for the join.
Left, Right PlanNode
// join strategy.
Strategy JoinStrategy
// Cols defines which columns from left or right results used to build the return result.
// For results coming from left, the values go as -1, -2, etc. For right, they're 1, 2, etc.
// If Cols is {-1, -2, 1, 2}, it means the returned result is {Left0, Left1, Right0, Right1}.
Cols []int `json:",omitempty"`
// eg: from t1 join t2 on t1.a=t2.b, 't1.a' put in LeftKeys, 't2.a' in RightKeys.
LeftKeys, RightKeys []JoinKey
// eg: t1 join t2 on t1.a>t2.a, 't1.a>t2.a' parser into CmpFilter.
CmpFilter []Comparison
// whether is left join.
IsLeftJoin bool
// whether the right node has filters in left join.
HasRightFilter bool
// record the `otherJoin.left`'s index in left.fields.
LeftTmpCols []int
// record the `rightNull`'s index in right.fields.
RightTmpCols []int
// Vars defines the list of joinVars that need to be built
// from the Left result before invoking the Right subqquery.
Vars map[string]int
// contains filtered or unexported fields
}
JoinNode cannot be pushed down.
func (*JoinNode) GetQuery ¶ added in v1.0.5
func (j *JoinNode) GetQuery() []xcontext.QueryTuple
GetQuery used to get the Querys.
type JoinStrategy ¶ added in v1.0.6
type JoinStrategy int
JoinStrategy is Join Strategy.
const ( // Cartesian product. Cartesian JoinStrategy = iota // SortMerge Join. SortMerge // NestedLoop Join. NestedLoop )
type LimitPlan ¶
LimitPlan represents order-by plan.
func NewLimitPlan ¶
NewLimitPlan used to create LimitPlan.
type MergeNode ¶ added in v1.0.5
type MergeNode struct { // select ast. Sel *sqlparser.Select // query and backend tuple Querys []xcontext.QueryTuple // querys with bind locations. ParsedQuerys []*sqlparser.ParsedQuery // contains filtered or unexported fields }
MergeNode can be pushed down.
func (*MergeNode) GetQuery ¶ added in v1.0.5
func (m *MergeNode) GetQuery() []xcontext.QueryTuple
GetQuery used to get the Querys.
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, tbInfos map[string]*TableInfo) *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.
type OthersPlan ¶ added in v1.0.6
type OthersPlan struct { // raw query RawQuery string // mode ReqMode xcontext.RequestMode // query and backend tuple Querys []xcontext.QueryTuple // contains filtered or unexported fields }
OthersPlan -- represents a special plan.
func NewOthersPlan ¶ added in v1.0.6
func NewOthersPlan(log *xlog.Log, database string, query string, node sqlparser.Statement, router *router.Router) *OthersPlan
NewOthersPlan -- used to create OthersPlan.
func (*OthersPlan) Build ¶ added in v1.0.6
func (p *OthersPlan) Build() error
Build used to build distributed querys.
func (*OthersPlan) Children ¶ added in v1.0.6
func (p *OthersPlan) Children() *PlanTree
Children returns the children of the plan.
func (*OthersPlan) JSON ¶ added in v1.0.6
func (p *OthersPlan) JSON() string
JSON returns the plan info.
func (*OthersPlan) Size ¶ added in v1.0.6
func (p *OthersPlan) Size() int
Size returns the memory size.
func (*OthersPlan) Type ¶ added in v1.0.6
func (p *OthersPlan) Type() PlanType
Type returns the type of the plan.
type PlanNode ¶ added in v1.0.5
type PlanNode interface { Children() *PlanTree GetQuery() []xcontext.QueryTuple Order() int // contains filtered or unexported methods }
PlanNode interface.
type PlanTree ¶
type PlanTree struct {
// contains filtered or unexported fields
}
PlanTree is a container for all plans
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" // PlanTypeOthers enum. PlanTypeOthers PlanType = "PlanTypeOthers" )
type SelectPlan ¶
type SelectPlan struct { // raw query RawQuery string // mode ReqMode xcontext.RequestMode Root PlanNode // 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.
type TableInfo ¶ added in v1.0.3
type TableInfo struct { // table's route. Segments []router.Segment `json:",omitempty"` // contains filtered or unexported fields }
TableInfo represents one table information.
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.