-
Notifications
You must be signed in to change notification settings - Fork 264
/
types.go
130 lines (119 loc) · 3.43 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2021 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package compile
import (
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
"github.com/matrixorigin/matrixone/pkg/sql/plan"
"github.com/matrixorigin/matrixone/pkg/vm"
"github.com/matrixorigin/matrixone/pkg/vm/engine"
"github.com/matrixorigin/matrixone/pkg/vm/process"
)
// type of scope
const (
Merge = iota
Normal
Remote
Parallel
Insert
CreateDatabase
CreateTable
CreateIndex
DropDatabase
DropTable
DropIndex
ShowDatabases
ShowTables
ShowColumns
ShowCreateTable
ShowCreateDatabase
Delete
Update
)
// type of query
const (
BQ = iota // bare query
AQ // aggregation query
CQ // conjunctive query
CAQ // conjunctive aggregation query
)
// Address is the ip:port of local node
var Address string
// Source contains information of a relation which will be used in execution,
type Source struct {
IsMerge bool
SchemaName string
RelationName string
RefCounts []uint64
Attributes []string
R engine.Reader
}
// Scope is the output of the compile process.
// Each sql will be compiled to one or more execution unit scopes.
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
}
// Col is the information of attribute
type Col struct {
Typ types.T
Name string
}
// Exec stores all information related to the execution phase of a single sql.
type Exec struct {
//err stores err information if error occurred during execution.
// err error
//resultCols stores the column information of result.
resultCols []*Col
scope *Scope
c *compile
//affectRows stores the number of rows affected while insert / update / delete
affectRows uint64
//e is a db engine instance
e engine.Engine
//stmt ast of a single sql
stmt tree.Statement
u interface{}
//fill is a result writer runs a callback function.
//fill will be called when result data is ready.
fill func(interface{}, *batch.Batch) error
}
// compile contains all the information needed for compilation.
type compile struct {
// db current database name.
db string
// uid the user who initiated the sql.
uid string
// sql sql text.
sql string
// e db engine instance.
e engine.Engine
// proc stores the execution context.
proc *process.Process
}