Skip to content

Commit

Permalink
*: make schema as a pointer. (pingcap#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored Jan 23, 2017
1 parent de9b134 commit fb42940
Show file tree
Hide file tree
Showing 32 changed files with 191 additions and 179 deletions.
4 changes: 2 additions & 2 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type MockExec struct {
curRowIdx int
}

func (m *MockExec) Schema() expression.Schema {
return expression.Schema{}
func (m *MockExec) Schema() *expression.Schema {
return expression.NewSchema()
}

func (m *MockExec) Fields() []*ast.ResultField {
Expand Down
64 changes: 32 additions & 32 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ type RowKeyEntry struct {
type Executor interface {
Next() (*Row, error)
Close() error
Schema() expression.Schema
Schema() *expression.Schema
}

// ShowDDLExec represents a show DDL executor.
type ShowDDLExec struct {
schema expression.Schema
schema *expression.Schema
ctx context.Context
ddlInfo *inspectkv.DDLInfo
bgInfo *inspectkv.DDLInfo
done bool
}

// Schema implements the Executor Schema interface.
func (e *ShowDDLExec) Schema() expression.Schema {
func (e *ShowDDLExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -172,8 +172,8 @@ type CheckTableExec struct {
}

// Schema implements the Executor Schema interface.
func (e *CheckTableExec) Schema() expression.Schema {
return expression.NewSchema(nil)
func (e *CheckTableExec) Schema() *expression.Schema {
return expression.NewSchema()
}

// Next implements the Executor Next interface.
Expand Down Expand Up @@ -217,11 +217,11 @@ type SelectLockExec struct {
Src Executor
Lock ast.SelectLockType
ctx context.Context
schema expression.Schema
schema *expression.Schema
}

// Schema implements the Executor Schema interface.
func (e *SelectLockExec) Schema() expression.Schema {
func (e *SelectLockExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -260,11 +260,11 @@ type LimitExec struct {
Offset uint64
Count uint64
Idx uint64
schema expression.Schema
schema *expression.Schema
}

// Schema implements the Executor Schema interface.
func (e *LimitExec) Schema() expression.Schema {
func (e *LimitExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -315,7 +315,7 @@ type ReverseExec struct {
}

// Schema implements the Executor Schema interface.
func (e *ReverseExec) Schema() expression.Schema {
func (e *ReverseExec) Schema() *expression.Schema {
return e.Src.Schema()
}

Expand Down Expand Up @@ -381,14 +381,14 @@ func init() {
// ProjectionExec represents a select fields executor.
type ProjectionExec struct {
Src Executor
schema expression.Schema
schema *expression.Schema
executed bool
ctx context.Context
exprs []expression.Expression
}

// Schema implements the Executor Schema interface.
func (e *ProjectionExec) Schema() expression.Schema {
func (e *ProjectionExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -436,7 +436,7 @@ func (e *ProjectionExec) Close() error {

// TableDualExec represents a dual table executor.
type TableDualExec struct {
schema expression.Schema
schema *expression.Schema
executed bool
}

Expand All @@ -446,7 +446,7 @@ func (e *TableDualExec) Init() {
}

// Schema implements the Executor Schema interface.
func (e *TableDualExec) Schema() expression.Schema {
func (e *TableDualExec) Schema() *expression.Schema {
return e.schema
}

Expand All @@ -469,11 +469,11 @@ type SelectionExec struct {
Src Executor
Condition expression.Expression
ctx context.Context
schema expression.Schema
schema *expression.Schema
}

// Schema implements the Executor Schema interface.
func (e *SelectionExec) Schema() expression.Schema {
func (e *SelectionExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -511,7 +511,7 @@ type TableScanExec struct {
seekHandle int64
iter kv.Iterator
cursor int
schema expression.Schema
schema *expression.Schema
columns []*model.ColumnInfo

isInfoSchema bool
Expand All @@ -520,7 +520,7 @@ type TableScanExec struct {
}

// Schema implements the Executor Schema interface.
func (e *TableScanExec) Schema() expression.Schema {
func (e *TableScanExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -648,7 +648,7 @@ type SortExec struct {
Idx int
fetched bool
err error
schema expression.Schema
schema *expression.Schema
}

// Close implements the Executor Close interface.
Expand All @@ -659,7 +659,7 @@ func (e *SortExec) Close() error {
}

// Schema implements the Executor Schema interface.
func (e *SortExec) Schema() expression.Schema {
func (e *SortExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -848,13 +848,13 @@ func (e *TopnExec) Next() (*Row, error) {

// ExistsExec represents exists executor.
type ExistsExec struct {
schema expression.Schema
schema *expression.Schema
Src Executor
evaluated bool
}

// Schema implements the Executor Schema interface.
func (e *ExistsExec) Schema() expression.Schema {
func (e *ExistsExec) Schema() *expression.Schema {
return e.schema
}

Expand All @@ -881,13 +881,13 @@ func (e *ExistsExec) Next() (*Row, error) {
// MaxOneRowExec checks if the number of rows that a query returns is at maximum one.
// It's built from subquery expression.
type MaxOneRowExec struct {
schema expression.Schema
schema *expression.Schema
Src Executor
evaluated bool
}

// Schema implements the Executor Schema interface.
func (e *MaxOneRowExec) Schema() expression.Schema {
func (e *MaxOneRowExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -925,13 +925,13 @@ func (e *MaxOneRowExec) Next() (*Row, error) {
// For example, in the 'SELECT a from t order by b' statement,
// 'b' is needed for ordering, but not needed in the result.
type TrimExec struct {
schema expression.Schema
schema *expression.Schema
Src Executor
len int
}

// Schema implements the Executor Schema interface.
func (e *TrimExec) Schema() expression.Schema {
func (e *TrimExec) Schema() *expression.Schema {
return e.schema
}

Expand All @@ -957,7 +957,7 @@ func (e *TrimExec) Next() (*Row, error) {
// UnionExec has multiple source Executors, it executes them sequentially, and do conversion to the same type
// as source Executors may has different field type, we need to do conversion.
type UnionExec struct {
schema expression.Schema
schema *expression.Schema
Srcs []Executor
ctx context.Context
inited bool
Expand All @@ -971,7 +971,7 @@ type UnionExec struct {
}

// Schema implements the Executor Schema interface.
func (e *UnionExec) Schema() expression.Schema {
func (e *UnionExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -1074,11 +1074,11 @@ func (e *UnionExec) Close() error {
// DummyScanExec returns zero results, when some where condition never match, there won't be any
// rows to return, so DummyScan is used to avoid real scan on KV.
type DummyScanExec struct {
schema expression.Schema
schema *expression.Schema
}

// Schema implements the Executor Schema interface.
func (e *DummyScanExec) Schema() expression.Schema {
func (e *DummyScanExec) Schema() *expression.Schema {
return e.schema
}

Expand All @@ -1095,15 +1095,15 @@ func (e *DummyScanExec) Next() (*Row, error) {
// CacheExec represents Cache executor.
// it stores the return values of the executor of its child node.
type CacheExec struct {
schema expression.Schema
schema *expression.Schema
Src Executor
storedRows []*Row
cursor int
srcFinished bool
}

// Schema implements the Executor Schema interface.
func (e *CacheExec) Schema() expression.Schema {
func (e *CacheExec) Schema() *expression.Schema {
return e.schema
}

Expand Down
8 changes: 4 additions & 4 deletions executor/executor_agg.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// and updates all the items in AggFuncs.
type HashAggExec struct {
Src Executor
schema expression.Schema
schema *expression.Schema
executed bool
hasGby bool
aggType plan.AggregationType
Expand All @@ -51,7 +51,7 @@ func (e *HashAggExec) Close() error {
}

// Schema implements the Executor Schema interface.
func (e *HashAggExec) Schema() expression.Schema {
func (e *HashAggExec) Schema() *expression.Schema {
return e.schema
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (e *HashAggExec) innerNext() (ret bool, err error) {
// When Next() is called, it will return a result for the same group.
type StreamAggExec struct {
Src Executor
schema expression.Schema
schema *expression.Schema
executed bool
hasData bool
Ctx context.Context
Expand All @@ -176,7 +176,7 @@ func (e *StreamAggExec) Close() error {
}

// Schema implements the Executor Schema interface.
func (e *StreamAggExec) Schema() expression.Schema {
func (e *StreamAggExec) Schema() *expression.Schema {
return e.schema
}

Expand Down
4 changes: 2 additions & 2 deletions executor/executor_ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type DDLExec struct {
}

// Schema implements the Executor Schema interface.
func (e *DDLExec) Schema() expression.Schema {
return expression.NewSchema(nil)
func (e *DDLExec) Schema() *expression.Schema {
return expression.NewSchema()
}

// Next implements Execution Next interface.
Expand Down
6 changes: 3 additions & 3 deletions executor/executor_distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ type XSelectIndexExec struct {
}

// Schema implements Exec Schema interface.
func (e *XSelectIndexExec) Schema() expression.Schema {
func (e *XSelectIndexExec) Schema() *expression.Schema {
return e.indexPlan.GetSchema()
}

Expand Down Expand Up @@ -762,7 +762,7 @@ type XSelectTableExec struct {

where *tipb.Expr
Columns []*model.ColumnInfo
schema expression.Schema
schema *expression.Schema
ranges []plan.TableRange
desc bool
limitCount *int64
Expand Down Expand Up @@ -790,7 +790,7 @@ type XSelectTableExec struct {
}

// Schema implements the Executor Schema interface.
func (e *XSelectTableExec) Schema() expression.Schema {
func (e *XSelectTableExec) Schema() *expression.Schema {
return e.schema
}

Expand Down
Loading

0 comments on commit fb42940

Please sign in to comment.