Skip to content

Commit f44e789

Browse files
author
James Cor
committed
refactor
1 parent b545e25 commit f44e789

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

server/handler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ 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 ri2, ok := rowIter.(sql.RowIter2); ok && ri2.IsRowIter2(sqlCtx) {
499-
r, processedAtLeastOneBatch, err = h.resultForDefaultIter2(sqlCtx, c, schema, ri2, resultFields, buf, callback, more)
498+
} else if vr, ok := rowIter.(sql.ValueRowIter); ok && vr.CanSupport(sqlCtx) {
499+
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)
502502
}
@@ -770,8 +770,8 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s
770770
return r, processedAtLeastOneBatch, nil
771771
}
772772

773-
func (h *Handler) resultForDefaultIter2(ctx *sql.Context, c *mysql.Conn, schema sql.Schema, iter sql.RowIter2, resultFields []*querypb.Field, buf *sql.ByteBuffer, callback func(*sqltypes.Result, bool) error, more bool) (*sqltypes.Result, bool, error) {
774-
defer trace.StartRegion(ctx, "Handler.resultForDefaultIter2").End()
773+
func (h *Handler) resultForValueRowIter(ctx *sql.Context, c *mysql.Conn, schema sql.Schema, iter sql.ValueRowIter, resultFields []*querypb.Field, buf *sql.ByteBuffer, callback func(*sqltypes.Result, bool) error, more bool) (*sqltypes.Result, bool, error) {
774+
defer trace.StartRegion(ctx, "Handler.resultForValueRowIter").End()
775775

776776
eg, ctx := ctx.NewErrgroup()
777777
pan2err := func(err *error) {
@@ -816,7 +816,7 @@ func (h *Handler) resultForDefaultIter2(ctx *sql.Context, c *mysql.Conn, schema
816816
case <-ctx.Done():
817817
return context.Cause(ctx)
818818
default:
819-
row, err := iter.Next2(ctx)
819+
row, err := iter.NextValueRow(ctx)
820820
if err == io.EOF {
821821
return nil
822822
}

sql/plan/filter.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ type FilterIter struct {
106106
childIter sql.RowIter
107107

108108
cond2 sql.Expression2
109-
childIter2 sql.RowIter2
109+
childIter2 sql.ValueRowIter
110110
}
111111

112112
var _ sql.RowIter = (*FilterIter)(nil)
113-
var _ sql.RowIter2 = (*FilterIter)(nil)
113+
var _ sql.ValueRowIter = (*FilterIter)(nil)
114114

115115
// NewFilterIter creates a new FilterIter.
116116
func NewFilterIter(
@@ -139,9 +139,9 @@ func (i *FilterIter) Next(ctx *sql.Context) (sql.Row, error) {
139139
}
140140
}
141141

142-
func (i *FilterIter) Next2(ctx *sql.Context) (sql.ValueRow, error) {
142+
func (i *FilterIter) NextValueRow(ctx *sql.Context) (sql.ValueRow, error) {
143143
for {
144-
row, err := i.childIter2.Next2(ctx)
144+
row, err := i.childIter2.NextValueRow(ctx)
145145
if err != nil {
146146
return nil, err
147147
}
@@ -155,13 +155,13 @@ func (i *FilterIter) Next2(ctx *sql.Context) (sql.ValueRow, error) {
155155
}
156156
}
157157

158-
func (i *FilterIter) IsRowIter2(ctx *sql.Context) bool {
158+
func (i *FilterIter) CanSupport(ctx *sql.Context) bool {
159159
cond, ok := i.cond.(sql.Expression2)
160160
if !ok || !cond.IsExpr2() {
161161
return false
162162
}
163-
childIter, ok := i.childIter.(sql.RowIter2)
164-
if !ok || !childIter.IsRowIter2(ctx) {
163+
childIter, ok := i.childIter.(sql.ValueRowIter)
164+
if !ok || !childIter.CanSupport(ctx) {
165165
return false
166166
}
167167
i.cond2 = cond

sql/plan/process.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const (
226226
type TrackedRowIter struct {
227227
node sql.Node
228228
iter sql.RowIter
229-
iter2 sql.RowIter2
229+
iter2 sql.ValueRowIter
230230
onDone NotifyFunc
231231
onNext NotifyFunc
232232
numRows int64
@@ -318,8 +318,8 @@ func (i *TrackedRowIter) Next(ctx *sql.Context) (sql.Row, error) {
318318
return row, nil
319319
}
320320

321-
func (i *TrackedRowIter) Next2(ctx *sql.Context) (sql.ValueRow, error) {
322-
row, err := i.iter2.Next2(ctx)
321+
func (i *TrackedRowIter) NextValueRow(ctx *sql.Context) (sql.ValueRow, error) {
322+
row, err := i.iter2.NextValueRow(ctx)
323323
if err != nil {
324324
return nil, err
325325
}
@@ -330,9 +330,9 @@ func (i *TrackedRowIter) Next2(ctx *sql.Context) (sql.ValueRow, error) {
330330
return row, nil
331331
}
332332

333-
func (i *TrackedRowIter) IsRowIter2(ctx *sql.Context) bool {
334-
iter, ok := i.iter.(sql.RowIter2)
335-
if !ok || !iter.IsRowIter2(ctx) {
333+
func (i *TrackedRowIter) CanSupport(ctx *sql.Context) bool {
334+
iter, ok := i.iter.(sql.ValueRowIter)
335+
if !ok || !iter.CanSupport(ctx) {
336336
return false
337337
}
338338
i.iter2 = iter

sql/rowexec/transaction_iters.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func getLockableTable(table sql.Table) (sql.Lockable, error) {
7171
// during the Close() operation
7272
type TransactionCommittingIter struct {
7373
childIter sql.RowIter
74-
childIter2 sql.RowIter2
74+
childIter2 sql.ValueRowIter
7575
transactionDatabase string
7676
autoCommit bool
7777
implicitCommit bool
@@ -100,13 +100,13 @@ func (t *TransactionCommittingIter) Next(ctx *sql.Context) (sql.Row, error) {
100100
return t.childIter.Next(ctx)
101101
}
102102

103-
func (t *TransactionCommittingIter) Next2(ctx *sql.Context) (sql.ValueRow, error) {
104-
return t.childIter2.Next2(ctx)
103+
func (t *TransactionCommittingIter) NextValueRow(ctx *sql.Context) (sql.ValueRow, error) {
104+
return t.childIter2.NextValueRow(ctx)
105105
}
106106

107-
func (t *TransactionCommittingIter) IsRowIter2(ctx *sql.Context) bool {
108-
childIter, ok := t.childIter.(sql.RowIter2)
109-
if !ok || !childIter.IsRowIter2(ctx) {
107+
func (t *TransactionCommittingIter) CanSupport(ctx *sql.Context) bool {
108+
childIter, ok := t.childIter.(sql.ValueRowIter)
109+
if !ok || !childIter.CanSupport(ctx) {
110110
return false
111111
}
112112
t.childIter2 = childIter

sql/rows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ type RowIter interface {
8888
Closer
8989
}
9090

91-
type RowIter2 interface {
91+
type ValueRowIter interface {
9292
RowIter
93-
Next2(ctx *Context) (ValueRow, error)
94-
IsRowIter2(ctx *Context) bool
93+
NextValueRow(ctx *Context) (ValueRow, error)
94+
CanSupport(ctx *Context) bool
9595
}
9696

9797
// RowIterToRows converts a row iterator to a slice of rows.

sql/table_iter.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type TableRowIter struct {
2626
partition Partition
2727
rows RowIter
2828

29-
rows2 RowIter2
29+
rows2 ValueRowIter
3030
}
3131

3232
var _ RowIter = (*TableRowIter)(nil)
@@ -79,7 +79,7 @@ func (i *TableRowIter) Next(ctx *Context) (Row, error) {
7979
return row, err
8080
}
8181

82-
func (i *TableRowIter) Next2(ctx *Context) (ValueRow, error) {
82+
func (i *TableRowIter) NextValueRow(ctx *Context) (ValueRow, error) {
8383
select {
8484
case <-ctx.Done():
8585
return nil, ctx.Err()
@@ -105,26 +105,26 @@ func (i *TableRowIter) Next2(ctx *Context) (ValueRow, error) {
105105
if err != nil {
106106
return nil, err
107107
}
108-
ri2, ok := rows.(RowIter2)
109-
if !ok || !ri2.IsRowIter2(ctx) {
110-
panic(fmt.Sprintf("%T does not implement RowIter2", rows))
108+
ri2, ok := rows.(ValueRowIter)
109+
if !ok || !ri2.CanSupport(ctx) {
110+
panic(fmt.Sprintf("%T does not implement ValueRowIter", rows))
111111
}
112112
i.rows2 = ri2
113113
}
114114

115-
row, err := i.rows2.Next2(ctx)
115+
row, err := i.rows2.NextValueRow(ctx)
116116
if err != nil && err == io.EOF {
117117
if err = i.rows2.Close(ctx); err != nil {
118118
return nil, err
119119
}
120120
i.partition = nil
121121
i.rows2 = nil
122-
row, err = i.Next2(ctx)
122+
row, err = i.NextValueRow(ctx)
123123
}
124124
return row, err
125125
}
126126

127-
func (i *TableRowIter) IsRowIter2(ctx *Context) bool {
127+
func (i *TableRowIter) CanSupport(ctx *Context) bool {
128128
if i.partition == nil {
129129
partition, err := i.partitions.Next(ctx)
130130
if err != nil {
@@ -137,13 +137,13 @@ func (i *TableRowIter) IsRowIter2(ctx *Context) bool {
137137
if err != nil {
138138
return false
139139
}
140-
ri2, ok := rows.(RowIter2)
140+
ri2, ok := rows.(ValueRowIter)
141141
if !ok {
142142
return false
143143
}
144144
i.rows2 = ri2
145145
}
146-
return i.rows2.IsRowIter2(ctx)
146+
return i.rows2.CanSupport(ctx)
147147
}
148148

149149
func (i *TableRowIter) Close(ctx *Context) error {

0 commit comments

Comments
 (0)