plan

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FULL = iota
	LEFT
	SEMI
	ANTI
	INNER
	CROSS
	RIGHT
	NATURAL
	RELATION
)

Variables

View Source
var (
	// ErrDivByZero is reported on a division by zero.
	ErrDivByZero = overload.ErrDivByZero
	// ErrZeroModulus is reported when computing the rest of a division by zero.
	ErrZeroModulus = overload.ErrModByZero
)

Functions

func Eq

func Eq(x, y *extend.ValueExtend) (extend.Extend, error)

func Ge

func Ge(x, y *extend.ValueExtend) (extend.Extend, error)

func Gt

func Gt(x, y *extend.ValueExtend) (extend.Extend, error)

func Le

func Le(x, y *extend.ValueExtend) (extend.Extend, error)

func Lt

func Lt(x, y *extend.ValueExtend) (extend.Extend, error)

func Ne

func Ne(x, y *extend.ValueExtend) (extend.Extend, error)

func Neg

func New

func New(db string, sql string, e engine.Engine) *build

Types

type Aggregation

type Aggregation struct {
	Op    int     //  opcode of aggregation function
	Ref   int     // reference count
	Type  types.T //  return type of aggregation function
	Name  string  //  name of attribute
	Alias string
	E     extend.Extend
}

type Attribute

type Attribute struct {
	Ref  int        // reference count
	Name string     // name of attribute
	Type types.Type // type of attribute
}

func (*Attribute) String

func (attr *Attribute) String() string

type CreateDatabase

type CreateDatabase struct {
	IfNotExistFlag bool
	Id             string
	E              engine.Engine
}

func (CreateDatabase) ResultColumns

func (c CreateDatabase) ResultColumns() []*Attribute

func (CreateDatabase) String

func (c CreateDatabase) String() string

type CreateIndex

type CreateIndex struct {
	IfNotExistFlag bool
	HasExist       bool // if true, means this index has existed.
	Id             string
	Relation       engine.Relation
	Defs           []engine.TableDef
}

func (CreateIndex) ResultColumns

func (c CreateIndex) ResultColumns() []*Attribute

func (CreateIndex) String

func (c CreateIndex) String() string

type CreateTable

type CreateTable struct {
	IfNotExistFlag bool
	Id             string
	Db             engine.Database
	Defs           []engine.TableDef
	PartitionBy    *engine.PartitionByDef
}

func (CreateTable) ResultColumns

func (c CreateTable) ResultColumns() []*Attribute

func (CreateTable) String

func (c CreateTable) String() string

type Dedup

type Dedup struct {
}

type Delete

type Delete struct {
	Qry *Query
}

func (Delete) ResultColumns

func (d Delete) ResultColumns() []*Attribute

func (Delete) String

func (d Delete) String() string

type DerivedRelation

type DerivedRelation struct {
	Proj Projection
	Cond extend.Extend

	Flg       bool // indicate if transform is required
	FreeVars  []string
	BoundVars []*Aggregation
}

type Direction

type Direction int8

Direction for ordering results.

const (
	DefaultDirection Direction = iota
	Ascending
	Descending
)

Direction values.

func (Direction) String

func (i Direction) String() string

type DropDatabase

type DropDatabase struct {
	IfExistFlag bool
	Id          string
	E           engine.Engine
}

func (DropDatabase) ResultColumns

func (d DropDatabase) ResultColumns() []*Attribute

func (DropDatabase) String

func (d DropDatabase) String() string

type DropIndex

type DropIndex struct {
	IfExistFlag bool
	NotExisted  bool // if true, means this index does not exist.
	Id          string
	Relation    engine.Relation
}

func (DropIndex) ResultColumns

func (d DropIndex) ResultColumns() []*Attribute

func (DropIndex) String

func (d DropIndex) String() string

type DropTable

type DropTable struct {
	IfExistFlag bool
	Ids         []string
	Dbs         []string
	E           engine.Engine
}

func (DropTable) ResultColumns

func (d DropTable) ResultColumns() []*Attribute

func (DropTable) String

func (d DropTable) String() string

type Edge

type Edge struct {
	Vs []int
}

type EdgeSet

type EdgeSet struct {
	W      int // weight
	I1, I2 int // subscript for E1 and E2
	E1, E2 *Edge
}

type Field

type Field struct {
	Attr string
	Type Direction
}

func (*Field) String

func (n *Field) String() string

type Graph

type Graph struct {
	Es []*Edge
}

type Insert

type Insert struct {
	Id       string
	Db       string
	Bat      *batch.Batch
	Relation engine.Relation
}

func (Insert) ResultColumns

func (i Insert) ResultColumns() []*Attribute

func (Insert) String

func (i Insert) String() string

type Join

type Join struct {
	Type   int // join type
	Vars   [][]int
	Result []string
}

type JoinCondition

type JoinCondition struct {
	R     int
	S     int
	Rattr string
	Sattr string

	Alias int
}

R.Rattr = S.Sattr

type Limit

type Limit struct {
	Limit int64
}

type Offset

type Offset struct {
	Offset int64
}

type Order

type Order struct {
	Fs []*Field
}

type Plan

type Plan interface {
	fmt.Stringer
	ResultColumns() []*Attribute
}

type Projection

type Projection struct {
	Rs []uint64 // reference count list
	As []string // alias name list
	Es []extend.Extend
}

type Query

type Query struct {
	Flg        bool // rebuild flag
	Scope      *Scope
	Result     []string
	Stack      []*ScopeSet
	Aggs       []*Aggregation
	RenameRels map[string]*Scope
	Rels       map[string]map[string]*Scope

	Children []*Scope // subquery
}

func (*Query) Clear

func (qry *Query) Clear()

func (*Query) IsEmpty

func (qry *Query) IsEmpty() bool

func (*Query) Pop

func (qry *Query) Pop() *ScopeSet

func (*Query) Push

func (qry *Query) Push(ss *ScopeSet)

func (*Query) ResultColumns

func (qry *Query) ResultColumns() []*Attribute

func (*Query) String

func (qry *Query) String() string

func (*Query) Top

func (qry *Query) Top() *ScopeSet

type Relation

type Relation struct {
	Rows   int64
	Name   string                // table name
	Schema string                // schema name
	Attrs  map[string]*Attribute // table's column information

	Flg  bool // indicate if transform is required
	Proj Projection
	Cond extend.Extend

	FreeVars  []string
	BoundVars []*Aggregation
}

type Rename

type Rename struct {
	Rs []uint64 // reference count list
	As []string // alias name list
	Es []extend.Extend
}

type Restrict

type Restrict struct {
	E extend.Extend
}

type ResultAttributes

type ResultAttributes struct {
	Attrs    []string
	AttrsMap map[string]*Attribute
}

type ResultProjection

type ResultProjection struct {
	Rs []uint64 // reference count list
	As []string // alias name list
	Es []extend.Extend
}

type Scope

type Scope struct {
	Name     string
	Children []*Scope
	Op       interface{}
	Result   ResultAttributes
}

func (*Scope) Prune

func (s *Scope) Prune(attrsMap map[string]uint64, fvars []string)

func (*Scope) Rows

func (s *Scope) Rows() int64

rough estimate

type ScopeSet

type ScopeSet struct {
	JoinType int
	Scopes   []*Scope
	Conds    []*JoinCondition
}

type ShowColumns

type ShowColumns struct {
	Relation engine.Relation
	Like     []byte
}

func (ShowColumns) ResultColumns

func (s ShowColumns) ResultColumns() []*Attribute

func (ShowColumns) String

func (s ShowColumns) String() string

type ShowCreateDatabase

type ShowCreateDatabase struct {
	IfNotExistFlag bool
	Id             string
	E              engine.Engine
}

func (ShowCreateDatabase) ResultColumns

func (d ShowCreateDatabase) ResultColumns() []*Attribute

func (ShowCreateDatabase) String

func (d ShowCreateDatabase) String() string

type ShowCreateTable

type ShowCreateTable struct {
	Relation  engine.Relation
	TableName string
}

func (ShowCreateTable) ResultColumns

func (s ShowCreateTable) ResultColumns() []*Attribute

func (ShowCreateTable) String

func (s ShowCreateTable) String() string

type ShowDatabases

type ShowDatabases struct {
	E    engine.Engine
	Like []byte
}

func (ShowDatabases) ResultColumns

func (s ShowDatabases) ResultColumns() []*Attribute

func (ShowDatabases) String

func (s ShowDatabases) String() string

type ShowTables

type ShowTables struct {
	Db   engine.Database
	Like []byte
}

func (ShowTables) ResultColumns

func (s ShowTables) ResultColumns() []*Attribute

func (ShowTables) String

func (s ShowTables) String() string

type SymbolTable

type SymbolTable struct {
	Entries map[string]*Attribute
}

type Untransform

type Untransform struct {
	FreeVars []string
}

type Update

type Update struct {
	Qry         *Query
	UpdateList  []extend.UpdateExtend
	UpdateAttrs []string
	OtherAttrs  []string
}

func (Update) ResultColumns

func (p Update) ResultColumns() []*Attribute

func (Update) String

func (p Update) String() string

type VertexSet

type VertexSet struct {
	Is []int
	Es []*Edge
}

func (*VertexSet) Contains

func (vp *VertexSet) Contains(j int) bool

Jump to

Keyboard shortcuts

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