Skip to content

Commit d642bd3

Browse files
author
James Cor
committed
feedback
1 parent 50ed238 commit d642bd3

28 files changed

+94
-90
lines changed

server/handler.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (h *Handler) doQuery(
495495
r, err = resultForEmptyIter(sqlCtx, rowIter, resultFields)
496496
} else if analyzer.FlagIsSet(qFlags, sql.QFlagMax1Row) {
497497
r, err = resultForMax1RowIter(sqlCtx, schema, rowIter, resultFields, buf)
498-
} else if vr, ok := rowIter.(sql.ValueRowIter); ok && vr.CanSupport(sqlCtx) {
498+
} else if vr, ok := rowIter.(sql.ValueRowIter); ok && vr.IsValueRowIter(sqlCtx) {
499499
r, processedAtLeastOneBatch, err = h.resultForValueRowIter(sqlCtx, c, schema, vr, resultFields, buf, callback, more)
500500
} else {
501501
r, processedAtLeastOneBatch, err = h.resultForDefaultIter(sqlCtx, c, schema, rowIter, callback, resultFields, more, buf)
@@ -702,10 +702,7 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
702702
defer wg.Done()
703703
for {
704704
if r == nil {
705-
r = &sqltypes.Result{
706-
Rows: make([][]sqltypes.Value, 0, rowsBatch),
707-
Fields: resultFields,
708-
}
705+
r = &sqltypes.Result{Fields: resultFields}
709706
}
710707
if r.RowsAffected == rowsBatch {
711708
if err := resetCallback(r, more); err != nil {
@@ -1203,13 +1200,13 @@ func RowValueToSQLValues(ctx *sql.Context, sch sql.Schema, row sql.ValueRow, buf
12031200
continue
12041201
}
12051202
if buf == nil {
1206-
outVals[i], err = valType.ToSQLValue(ctx, row[i], nil)
1203+
outVals[i], err = valType.SQLValue(ctx, row[i], nil)
12071204
if err != nil {
12081205
return nil, err
12091206
}
12101207
continue
12111208
}
1212-
outVals[i], err = valType.ToSQLValue(ctx, row[i], buf.Get())
1209+
outVals[i], err = valType.SQLValue(ctx, row[i], buf.Get())
12131210
if err != nil {
12141211
return nil, err
12151212
}

sql/cache.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ func (l *lruCache) Dispose() {
7171
}
7272

7373
type rowsCache struct {
74-
memory Freeable
75-
reporter Reporter
76-
rows []Row
77-
rows2 []ValueRow
74+
memory Freeable
75+
reporter Reporter
76+
rows []Row
77+
valueRows []ValueRow
7878
}
7979

8080
func newRowsCache(memory Freeable, r Reporter) *rowsCache {
@@ -92,17 +92,17 @@ func (c *rowsCache) Add(row Row) error {
9292

9393
func (c *rowsCache) Get() []Row { return c.rows }
9494

95-
func (c *rowsCache) Add2(row2 ValueRow) error {
95+
func (c *rowsCache) AddValueRow(row ValueRow) error {
9696
if !releaseMemoryIfNeeded(c.reporter, c.memory.Free) {
9797
return ErrNoMemoryAvailable.New()
9898
}
9999

100-
c.rows2 = append(c.rows2, row2)
100+
c.valueRows = append(c.valueRows, row)
101101
return nil
102102
}
103103

104-
func (c *rowsCache) Get2() []ValueRow {
105-
return c.rows2
104+
func (c *rowsCache) GetValueRow() []ValueRow {
105+
return c.valueRows
106106
}
107107

108108
func (c *rowsCache) Dispose() {

sql/core.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ type ValueExpression interface {
465465
Expression
466466
// EvalValue evaluates the given row frame and returns a result.
467467
EvalValue(ctx *Context, row ValueRow) (Value, error)
468-
// CanSupport indicates whether this expression and all its children support ValueExpression.
469-
CanSupport() bool
468+
// IsValueExpression indicates whether this expression and all its children support ValueExpression.
469+
IsValueExpression() bool
470470
}
471471

472472
var SystemVariables SystemVariableRegistry

sql/expression/comparison.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,20 +566,20 @@ func (gt *GreaterThan) EvalValue(ctx *sql.Context, row sql.ValueRow) (sql.Value,
566566
return res, nil
567567
}
568568

569-
// CanSupport implements the ValueExpression interface.
570-
func (gt *GreaterThan) CanSupport() bool {
569+
// IsValueRowIter implements the ValueExpression interface.
570+
func (gt *GreaterThan) IsValueExpression() bool {
571571
l, ok := gt.comparison.LeftChild.(sql.ValueExpression)
572572
if !ok {
573573
return false
574574
}
575-
if !l.CanSupport() {
575+
if !l.IsValueExpression() {
576576
return false
577577
}
578578
r, ok := gt.comparison.RightChild.(sql.ValueExpression)
579579
if !ok {
580580
return false
581581
}
582-
if !r.CanSupport() {
582+
if !r.IsValueExpression() {
583583
return false
584584
}
585585
return true

sql/expression/get_field.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ func (p *GetField) EvalValue(ctx *sql.Context, row sql.ValueRow) (sql.Value, err
149149
return row[p.fieldIndex], nil
150150
}
151151

152-
// CanSupport implements the ValueExpression interface.
153-
func (p *GetField) CanSupport() bool {
152+
// IsValueRowIter implements the ValueExpression interface.
153+
func (p *GetField) IsValueExpression() bool {
154154
return true
155155
}
156156

sql/expression/literal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ func (lit *Literal) EvalValue(ctx *sql.Context, row sql.ValueRow) (sql.Value, er
141141
return lit.val2, nil
142142
}
143143

144-
// CanSupport implements the ValueExpression interface.
145-
func (lit *Literal) CanSupport() bool {
144+
// IsValueRowIter implements the ValueExpression interface.
145+
func (lit *Literal) IsValueExpression() bool {
146146
return types.IsInteger(lit.Typ)
147147
}
148148

sql/expression/sort.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,19 @@ func (s *Sorter) Less(i, j int) bool {
8686
return false
8787
}
8888

89-
// Sorter2 is a version of Sorter that operates on ValueRow
90-
type Sorter2 struct {
89+
// ValueRowSorter is a version of Sorter that operates on ValueRow
90+
type ValueRowSorter struct {
9191
LastError error
9292
Ctx *sql.Context
9393
SortFields []sql.SortField
9494
Rows []sql.ValueRow
9595
}
9696

97-
func (s *Sorter2) Len() int {
97+
func (s *ValueRowSorter) Len() int {
9898
return len(s.Rows)
9999
}
100100

101-
func (s *Sorter2) Swap(i, j int) {
101+
func (s *ValueRowSorter) Swap(i, j int) {
102102
s.Rows[i], s.Rows[j] = s.Rows[j], s.Rows[i]
103103
}
104104

sql/expression/unresolved.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func (uc *UnresolvedColumn) EvalValue(ctx *sql.Context, row sql.ValueRow) (sql.V
7676
panic("unresolved column is a placeholder node, but EvalValue was called")
7777
}
7878

79-
// CanSupport implements the ValueExpression interface.
80-
func (uc *UnresolvedColumn) CanSupport() bool {
81-
panic("unresolved column is a placeholder node, but CanSupport was called")
79+
// IsValueRowIter implements the ValueExpression interface.
80+
func (uc *UnresolvedColumn) IsValueExpression() bool {
81+
panic("unresolved column is a placeholder node, but IsValueExpression was called")
8282
}
8383

8484
// Name implements the Nameable interface.

sql/memory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ type Rows2Cache interface {
7070
// Add2 a new row to the cache. If there is no memory available, it will try to
7171
// free some memory. If after that there is still no memory available, it
7272
// will return an error and erase all the content of the cache.
73-
Add2(ValueRow) error
73+
AddValueRow(ValueRow) error
7474
// Get2 gets all rows.
75-
Get2() []ValueRow
75+
GetValueRow() []ValueRow
7676
}
7777

7878
// ErrNoMemoryAvailable is returned when there is no more available memory.

sql/plan/filter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ func (i *FilterIter) NextValueRow(ctx *sql.Context) (sql.ValueRow, error) {
154154
}
155155

156156
// CanSupport implements the sql.ValueRowIter interface.
157-
func (i *FilterIter) CanSupport(ctx *sql.Context) bool {
157+
func (i *FilterIter) IsValueRowIter(ctx *sql.Context) bool {
158158
cond, ok := i.cond.(sql.ValueExpression)
159-
if !ok || !cond.CanSupport() {
159+
if !ok || !cond.IsValueExpression() {
160160
return false
161161
}
162162
childIter, ok := i.childIter.(sql.ValueRowIter)
163-
if !ok || !childIter.CanSupport(ctx) {
163+
if !ok || !childIter.IsValueRowIter(ctx) {
164164
return false
165165
}
166166
return true

0 commit comments

Comments
 (0)