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

expression: support vectorized execution of expressions #5184

Merged
merged 8 commits into from
Nov 22, 2017

Conversation

zz-jason
Copy link
Member

No description provided.

func evalOneColumn(sc *stmtctx.StatementContext, expr Expression, input, output *chunk.Chunk, colID int) error {
switch fieldType, evalType := expr.GetType(), expr.GetType().EvalType(); evalType {
case types.ETInt:
for rowID, length := 0, input.NumRows(); rowID < length; rowID++ {
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 switch to assign a function to avoid loop in each case.

var execFunc func
switch {
case types.ETInt:
    execFunc = executeToInt
}
for rowID, length := 0, input.NumRows(); rowID < length; rowID++   {
    execFunc()
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is already simple enough and there is no need to bring the latency of function addressing.

@breezewish
Copy link
Member

any benchmarks?

@@ -0,0 +1,278 @@
// Copyright 2016 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.

2016 -> 2017

@coocood
Copy link
Member

coocood commented Nov 22, 2017

LGTM

alivxxx
alivxxx previously approved these changes Nov 22, 2017
Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

func evalOneColumn(sc *stmtctx.StatementContext, expr Expression, input, output *chunk.Chunk, colID int) error {
switch fieldType, evalType := expr.GetType(), expr.GetType().EvalType(); evalType {
case types.ETInt:
for rowID, length := 0, input.NumRows(); rowID < length; rowID++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/ rowID < length/ err != nil && rowID < length
and extract the err check code

switch fieldType, evalType := expr.GetType(), expr.GetType().EvalType(); evalType {
case types.ETInt:
err := executeToInt(sc, expr, fieldType, input, output, rowID, colID)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

extract the error check code

@zimulala
Copy link
Contributor

/run-all-tests

@coocood coocood merged commit ced6efc into pingcap:master Nov 22, 2017
@zz-jason zz-jason deleted the dev/chunk/vectorized branch December 29, 2017 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants