-
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: split interface Executor to a single package #6800
Conversation
@tiancaiamao PTAL |
/run-all-tests |
executor/operator/operator.go
Outdated
@@ -0,0 +1,154 @@ | |||
// Copyright 2015 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.
The year should be 2018.
Will the structure become the following?
Or:
|
And the the structs whose name is end with |
@winoros Both ways are acceptable, I think we can just remove the |
…into dev/split-executor
@@ -356,7 +357,7 @@ func (a *ExecStmt) logSlowQuery(txnTS uint64, succ bool) { | |||
} | |||
|
|||
// IsPointGetWithPKOrUniqueKeyByAutoCommit returns true when meets following conditions: | |||
// 1. ctx is auto commit tagged | |||
// 1. Sctx is auto commit tagged |
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 think SeCtx
or SCtx
is better.
// A typical usage of this function is: | ||
// chk := operator.NewChunk() | ||
// err := operator.Next(ctx, chk) | ||
NewChunk() *chunk.Chunk |
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.
Is this really necessary to be in the Operator interface, as long as []*types.FieldType
is provided ?
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.
In the OO style, any Operator inherit a BaseOperator, so those methods are get from BaseOperator for free.
In Go, interface should be minimal so they can be composed more easy.
The more methods an interface contains, the less flexible it is.
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 do it in another PR, for these PRs, we just move code.
|
||
// RetTypes returns the types of all the output columns, which can be found | ||
// in the result of function Schema(). | ||
RetTypes() []*types.FieldType |
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.
Is this really necessary to be in the Operator interface, as long as Schema()
is provided ?
// interface in the basic way, Operator implementations should implement their | ||
// own methods if necessary. | ||
type BaseOperator struct { | ||
Sctx sessionctx.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.
How about move the BaseOperator
back to executor package, so those field need not to be exposed?
And we can better separate interface and implementation.
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.
Agree this comment. As for other comments, I'll leave them for further improvement. These kind of PRs should only focus on the refactoring of code positions.
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.
Oh, the whole plan is to move all the operator implementations into the new package "operator", during the development, we could have some operators inside the "operator" package, while other operators are outside that package. These fields are only exported temporarily. After all the operators are moved into that package, the exported field will be un-exported back.
This PR should be merged when release 2.1 is ready, for now I just leave it here for discussing. |
What have you changed? (mandatory)
This is the first step to split the
executor
package. Theexecutor
package is too large, which contains a lot of source files with different functionality:This pull request renames
Executor
toOperator
and move it to a new package namedoperator
. For further improvements, we can:joins
inside theoperator
package and move all the join implementations into itreaders
inside theoperator
package and move all the reader implementations into itWhat are the type of the changes (mandatory)?
How has this PR been tested (mandatory)?