compile

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 47 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
	CreateDatabase
	CreateTable
	CreateIndex
	DropDatabase
	DropTable
	DropIndex
	Deletion
	Insert
	Update
)

type of scope

Variables

View Source
var Address string

Address is the ip:port of local node

Functions

func InitAddress

func InitAddress(addr string)

InitAddress is used to set address of local node

func PrintScope added in v0.5.0

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

Print is to format scope list

Types

type Col

type Col struct {
	Typ  types.T
	Name string
}

Col is the information of attribute

type Compile added in v0.5.0

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

Compile contains all the information needed for compilation.

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 (*Compile) Compile added in v0.5.0

func (c *Compile) Compile(pn *plan.Plan, 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 (*Compile) GetAffectedRows added in v0.5.0

func (c *Compile) GetAffectedRows() uint64

func (*Compile) Run added in v0.5.0

func (c *Compile) Run(ts uint64) (err error)

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

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

	// used for dispatch
	DispatchAll bool

	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

	Reg *process.WaitRegister
}

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, snapshot engine.Snapshot, engine engine.Engine) error

func (*Scope) CreateIndex

func (s *Scope) CreateIndex(ts uint64, snapshot engine.Snapshot, engine engine.Engine) error

func (*Scope) CreateTable

func (s *Scope) CreateTable(ts uint64, snapshot engine.Snapshot, engine engine.Engine, dbName string) error

func (*Scope) Delete

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

func (*Scope) DispatchRun added in v0.5.0

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

func (*Scope) DropDatabase

func (s *Scope) DropDatabase(ts uint64, snapshot engine.Snapshot, engine engine.Engine) error

func (*Scope) DropIndex

func (s *Scope) DropIndex(ts uint64, snapshot engine.Snapshot, engine engine.Engine) error

func (*Scope) DropTable

func (s *Scope) DropTable(ts uint64, snapshot engine.Snapshot, engine engine.Engine) error

func (*Scope) Insert

func (s *Scope) Insert(ts uint64, snapshot engine.Snapshot, engine engine.Engine) (uint64, error)

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) NumCPU added in v0.5.0

func (s *Scope) NumCPU() int

Get the number of cpu's available for the current scope

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) Update

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

type Source

type Source struct {
	SchemaName   string
	RelationName string
	Attributes   []string
	R            engine.Reader
	Bat          *batch.Batch
}

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