-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executor: move tidb_reader code to its named files. #7065
Conversation
This is yet another PR splitting from #7016. I hope this one can be merge soon. |
@tiancaiamao @winoros If you have any time, please take a look. Thanks a ton, ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree that move the things of table reader to a separate file. but it seems that we don't need to move buildExplain
and buildTableReader
executor/table_reader.go
Outdated
@@ -0,0 +1,187 @@ | |||
// Copyright 2017 PingCAP, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/2017/2018
executor/table_reader.go
Outdated
"golang.org/x/net/context" | ||
) | ||
|
||
// TableReaderExecutor sends dag request and reads table data from kv layer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/dag/DAG ?
tipb "github.com/pingcap/tipb/go-tipb" | ||
"golang.org/x/net/context" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to move _ Executor = &TableReaderExecutor{}
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do so, actually. baseExecutor
implements all method of Executor
's interface. TableReaderExecutor
embed baseExecutor
as anonymous
variable which makes sure TableReaderExecutor
implementing Executor
interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use _ Executor = &TableReaderExecutor{}
to navigate codes and makes sure that TableReaderExecutor
implements the Executor
interface.
Do we need to rename |
executor/explain.go
Outdated
@@ -27,6 +28,19 @@ type ExplainExec struct { | |||
cursor int | |||
} | |||
|
|||
// buildExplain builds a explain executor. `e.rows` collects final result and | |||
// displays it in sql-shell. | |||
func (b *executorBuilder) buildExplain(v *plan.Explain) Executor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function should stay in the builder.go
executor/table_reader.go
Outdated
} | ||
|
||
// Close implements the Executor Close interface. | ||
func (e *TableReaderExecutor) Close() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch the function positions of Open()
and Close()
executor/table_reader.go
Outdated
return e, nil | ||
} | ||
|
||
func (b *executorBuilder) buildTableReader(v *plan.PhysicalTableReader) *TableReaderExecutor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function should stay in the builder.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
I think we can use this PR to split the distsql.go |
1b83b1f
to
333fd30
Compare
} | ||
|
||
e.resultHandler = &tableResultHandler{} | ||
firstPartRanges, secondPartRanges := splitRanges(e.ranges, e.keepOrder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The splitRanges
and tableResultHandler
should be moved too, it is used for the table reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's also used in index reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So put into a util_reader.go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave it remains in the distsql.go
3f21ecc
to
c5d3114
Compare
executor/table_reader.go
Outdated
return result, nil | ||
} | ||
|
||
func buildNoRangeTableReader(b *executorBuilder, v *plan.PhysicalTableReader) (*TableReaderExecutor, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be placed in builder.go
.
Please address comments @zhexuany |
executor/builder.go
Outdated
@@ -618,6 +618,8 @@ func (b *executorBuilder) buildDDL(v *plan.DDL) Executor { | |||
return e | |||
} | |||
|
|||
// buildExplain builds a explain executor. `e.rows` collects final result and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I it's probably not proper explain the internal functionality for ExplainExec
here. We could put the comment starts with "e.rows
collects final result and ..." to the ExplainExec
. Also, the result can not only be displays in the console, it can be any mysql client actually.
executor/builder.go
Outdated
@@ -1456,6 +1458,20 @@ func containsLimit(execs []*tipb.Executor) bool { | |||
return false | |||
} | |||
|
|||
func (b *executorBuilder) buildTableReader(v *plan.PhysicalTableReader) *TableReaderExecutor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better put it to the old place, which is after the definition of buildNoRangeTableReader
.
tipb "github.com/pingcap/tipb/go-tipb" | ||
"golang.org/x/net/context" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use _ Executor = &TableReaderExecutor{}
to navigate codes and makes sure that TableReaderExecutor
implements the Executor
interface.
} | ||
|
||
e.resultHandler = &tableResultHandler{} | ||
firstPartRanges, secondPartRanges := splitRanges(e.ranges, e.keepOrder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave it remains in the distsql.go
LGTM |
1 similar comment
LGTM |
What have you changed? (mandatory)
Just move code around.
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
No need to add the new test.
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
Nope
Does this PR affect tidb-ansible update? (mandatory)
Nope
Does this PR need to be added to the release notes? (mandatory)