Skip to content

Commit

Permalink
expression: implement vectorized evalutaion for `builtinConnectionIDS…
Browse files Browse the repository at this point in the history
…ig` (pingcap#13160)
  • Loading branch information
TennyZhuang authored and ngaut committed Nov 9, 2019
1 parent 99310b2 commit 92f4ec6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion expression/builtin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (b *builtinConnectionIDSig) Clone() builtinFunc {
func (b *builtinConnectionIDSig) evalInt(_ chunk.Row) (int64, bool, error) {
data := b.ctx.GetSessionVars()
if data == nil {
return 0, true, errors.Errorf("Missing session variable when evalue builtin")
return 0, true, errors.Errorf("Missing session variable `builtinConnectionIDSig.evalInt`")
}
return int64(data.ConnectionID), false, nil
}
Expand Down
15 changes: 13 additions & 2 deletions expression/builtin_info_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,22 @@ func (b *builtinDatabaseSig) vecEvalString(input *chunk.Chunk, result *chunk.Col
}

func (b *builtinConnectionIDSig) vectorized() bool {
return false
return true
}

func (b *builtinConnectionIDSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
data := b.ctx.GetSessionVars()
if data == nil {
return errors.Errorf("Missing session variable in `builtinConnectionIDSig.vecEvalInt`")
}
connectionID := int64(data.ConnectionID)
result.ResizeInt64(n, false)
i64s := result.Int64s()
for i := 0; i < n; i++ {
i64s[i] = connectionID
}
return nil
}

func (b *builtinTiDBVersionSig) vectorized() bool {
Expand Down
4 changes: 3 additions & 1 deletion expression/builtin_info_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ var vecBuiltinInfoCases = map[string][]vecExprBenchCase{
ast.TiDBIsDDLOwner: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{}},
},
ast.ConnectionID: {},
ast.ConnectionID: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{}},
},
ast.LastInsertId: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt}},
Expand Down

0 comments on commit 92f4ec6

Please sign in to comment.