compile

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: 62 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Merge = iota
	Normal
	Remote
	Parallel
	Insert
	CreateDatabase
	CreateTable
	CreateIndex
	DropDatabase
	DropTable
	DropIndex
	ShowDatabases
	ShowTables
	ShowColumns
	ShowCreateTable
	ShowCreateDatabase
	Delete
	Update
)

type of scope

View Source
const (
	BQ  = iota // bare query
	AQ         // aggregation query
	CQ         // conjunctive query
	CAQ        // conjunctive aggregation query
)

type of query

View Source
const (
	UnitLimit = 256
)

size limit on the number of tuples to be processed at a time

Variables

View Source
var Address string

Address is the ip:port of local node

View Source
var OneInt64s []int64

OneInt64s is a slice whose size is equal to UnitLimit and whose value is all 1

Functions

func InitAddress

func InitAddress(addr string)

InitAddress is used to set address of local node

func New

func New(db string, sql string, uid string,
	e engine.Engine, proc *process.Process) *compile

New is used to new an object of compile

func Print

func Print(prefix []byte, ss []*Scope)

Print is to format scope list

func Transfer

func Transfer(s *Scope) protocol.Scope

Transfer is used to transfer a Scope to protocol.Scope

func Untransfer

func Untransfer(s *Scope, ps protocol.Scope)

Untransfer is used to transfer a protocol.Scope to Scope

func UntransferIns

func UntransferIns(ins, pins vm.Instructions)

UntransferIns is used to transfer Instructions

Types

type Col

type Col struct {
	Typ  types.T
	Name string
}

Col is the information of attribute

type Exec

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

Exec stores all information related to the execution phase of a single sql.

func (*Exec) Columns

func (e *Exec) Columns() []*Col

func (*Exec) Compile

func (e *Exec) Compile(u interface{}, fill func(interface{}, *batch.Batch) error) (err error)

Compile is the entrance of the compute-layer, it compiles AST tree to scope list. A scope is an execution unit.

func (*Exec) GetAffectedRows

func (e *Exec) GetAffectedRows() uint64

func (*Exec) Run

func (e *Exec) Run(ts uint64) (err error)

Run is an important function of the compute-layer, it executes a single sql according to its scope

func (*Exec) SetSchema

func (e *Exec) SetSchema(db string) error

func (*Exec) Statement

func (e *Exec) Statement() tree.Statement

type Scope

type Scope struct {
	// Magic specifies the type of Scope.
	// 0 -  execution unit for reading data.
	// 1 -  execution unit for processing intermediate results.
	// 2 -  execution unit that requires remote call.
	Magic int

	Plan plan.Plan
	// DataSource stores information about data source.
	DataSource *Source
	// PreScopes contains children of this scope will inherit and execute.
	PreScopes []*Scope
	// NodeInfo contains the information about the remote node.
	NodeInfo engine.Node
	// Instructions contains command list of this scope.
	Instructions vm.Instructions
	// Proc contains the execution context.
	Proc *process.Process
}

Scope is the output of the compile process. Each sql will be compiled to one or more execution unit scopes.

func (*Scope) CreateDatabase

func (s *Scope) CreateDatabase(ts uint64) error

CreateDatabase do create database work according to create database plan.

func (*Scope) CreateIndex

func (s *Scope) CreateIndex(ts uint64) error

CreateIndex do create index work according to create index plan

func (*Scope) CreateTable

func (s *Scope) CreateTable(ts uint64) error

CreateTable do create table work according to create table plan.

func (*Scope) Delete

func (s *Scope) Delete(ts uint64, e engine.Engine) (uint64, error)

Delete will delete rows from a single of table

func (*Scope) DropDatabase

func (s *Scope) DropDatabase(ts uint64) error

DropDatabase do drop database work according to drop index plan

func (*Scope) DropIndex

func (s *Scope) DropIndex(ts uint64) error

DropIndex do drop index work according to drop index plan

func (*Scope) DropTable

func (s *Scope) DropTable(ts uint64) error

DropTable do drop table work according to drop table plan

func (*Scope) Insert

func (s *Scope) Insert(ts uint64) (uint64, error)

Insert will insert a batch into relation and return numbers of affectedRow

func (*Scope) MergeRun

func (s *Scope) MergeRun(e engine.Engine) error

MergeRun range and run the scope's pre-scopes by go-routine, and finally run itself to do merge work.

func (*Scope) ParallelRun

func (s *Scope) ParallelRun(e engine.Engine) error

ParallelRun try to execute the scope in parallel way.

func (*Scope) RemoteRun

func (s *Scope) RemoteRun(e engine.Engine) error

RemoteRun send the scope to a remote node (if target node is itself, it is same to function ParallelRun) and run it.

func (*Scope) Run

func (s *Scope) Run(e engine.Engine) (err error)

Run read data from storage engine and run the instructions of scope.

func (*Scope) RunAQ

func (s *Scope) RunAQ(e engine.Engine) error

RunAQ run the scope which sql is a query for single table with aggregate functions

func (*Scope) RunCAQ

func (s *Scope) RunCAQ(e engine.Engine, op *times.Argument) error

RunCAQ run the scope which sql is a query for conjunctive aggregation query

func (*Scope) RunCAQWithSubquery

func (s *Scope) RunCAQWithSubquery(e engine.Engine, op *times.Argument) error

RunCAQWithSubquery run the scope which sql is a query for conjunctive aggregation query

func (*Scope) RunCQ

func (s *Scope) RunCQ(e engine.Engine, op *join.Argument) error

RunCQ run the scope which sql is a query for conjunctive query

func (*Scope) RunCQWithSubquery

func (s *Scope) RunCQWithSubquery(e engine.Engine, op *join.Argument) error

RunCQWithSubquery run the scope which sql is a query for conjunctive query and fact table is subquery

func (*Scope) RunQ

func (s *Scope) RunQ(e engine.Engine) error

RunQ run the scope which sql is a query for single table and without any aggregate functions it will build a multi-layer merging structure according to the scope, and finally run it. For an example, if the input scope is

[transform -> order -> push]

and we assume that there are 4 Cores at the node, we will convert it to be

s1: [transform -> order -> push]  - - > m1
s2: [transform -> order -> push]  - - > m1
s3: [transform -> order -> push]  - - > m2
s4: [transform -> order -> push]  - - > m2
m1 : [mergeOrder -> push] - -  > m3
m2 : [mergeOrder -> push] - -  > m3
m3 : [mergeOrder -> push] - - > top scope

func (*Scope) ShowColumns

func (s *Scope) ShowColumns(u interface{}, fill func(interface{}, *batch.Batch) error) error

ShowColumns fill batch with column information of a table

func (*Scope) ShowCreateDatabase

func (s *Scope) ShowCreateDatabase(u interface{}, fill func(interface{}, *batch.Batch) error) error

ShowCreateDatabase fill batch with definition of a database

func (*Scope) ShowCreateTable

func (s *Scope) ShowCreateTable(u interface{}, fill func(interface{}, *batch.Batch) error) error

ShowCreateTable fill batch with definition of a table

func (*Scope) ShowDatabases

func (s *Scope) ShowDatabases(u interface{}, fill func(interface{}, *batch.Batch) error) error

ShowDatabases fill batch with all database names

func (*Scope) ShowTables

func (s *Scope) ShowTables(u interface{}, fill func(interface{}, *batch.Batch) error) error

ShowTables fill batch with all table names in a database

func (*Scope) Update

func (s *Scope) Update(ts uint64, e engine.Engine) (uint64, error)

Update will update rows from a single of table

type Source

type Source struct {
	IsMerge      bool
	SchemaName   string
	RelationName string
	RefCounts    []uint64
	Attributes   []string
	R            engine.Reader
}

Source contains information of a relation which will be used in execution,

Jump to

Keyboard shortcuts

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