Skip to content
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

Merged
merged 9 commits into from
Jul 19, 2018

Conversation

zhexuany
Copy link
Contributor

What have you changed? (mandatory)

Just move code around.

What is the type of the changes? (mandatory)

  • Improvement (non-breaking change which is an improvement to an existing feature)

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)

@zhexuany
Copy link
Contributor Author

This is yet another PR splitting from #7016. I hope this one can be merge soon.

@zhexuany
Copy link
Contributor Author

@tiancaiamao @winoros If you have any time, please take a look. Thanks a ton, ;)

@zhexuany zhexuany added status/all tests passed type/enhancement The issue or PR belongs to an enhancement. labels Jul 16, 2018
@zhexuany zhexuany mentioned this pull request Jul 16, 2018
3 tasks
Copy link
Member

@winoros winoros left a 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

@@ -0,0 +1,187 @@
// Copyright 2017 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/2017/2018

"golang.org/x/net/context"
)

// TableReaderExecutor sends dag request and reads table data from kv layer.
Copy link
Contributor

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"
)

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@zimulala
Copy link
Contributor

Do we need to rename distsql.go? It only has the IndexReaderExecutor and IndexLookUpExecutor now.

@tiancaiamao
Copy link
Contributor

@zz-jason also has a PR for refactor #6800
The downside of those refactor is that it's harder to cherry-pick bug fix to release-2.0 any longer.
Personally I'l happy with this kind of change. How about @shenli ?

@@ -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 {
Copy link
Member

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

}

// Close implements the Executor Close interface.
func (e *TableReaderExecutor) Close() error {
Copy link
Member

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()

return e, nil
}

func (b *executorBuilder) buildTableReader(v *plan.PhysicalTableReader) *TableReaderExecutor {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

@zz-jason
Copy link
Member

I think we can use this PR to split the distsql.go

@zhexuany zhexuany changed the title executor: move explain and tidb_reader code to their files. executor: move explain and tidb_reader code to their named files. Jul 17, 2018
}

e.resultHandler = &tableResultHandler{}
firstPartRanges, secondPartRanges := splitRanges(e.ranges, e.keepOrder)
Copy link
Contributor

@alivxxx alivxxx Jul 17, 2018

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DONE

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

return result, nil
}

func buildNoRangeTableReader(b *executorBuilder, v *plan.PhysicalTableReader) (*TableReaderExecutor, error) {
Copy link
Member

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.

@winoros winoros changed the title executor: move explain and tidb_reader code to their named files. executor: move tidb_reader code to its named files. Jul 17, 2018
@tiancaiamao
Copy link
Contributor

Please address comments @zhexuany

@@ -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
Copy link
Member

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.

@@ -1456,6 +1458,20 @@ func containsLimit(execs []*tipb.Executor) bool {
return false
}

func (b *executorBuilder) buildTableReader(v *plan.PhysicalTableReader) *TableReaderExecutor {
Copy link
Member

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"
)

Copy link
Member

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)
Copy link
Member

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

@zz-jason
Copy link
Member

LGTM

1 similar comment
@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 19, 2018
@tiancaiamao tiancaiamao merged commit 387a53a into pingcap:master Jul 19, 2018
@zhexuany zhexuany deleted the move_code_table_reader branch October 22, 2018 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT1 Indicates that a PR has LGTM 1. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants