Skip to content

Commit

Permalink
expression: implement vectorized evaluation for `builtinLastInsertIDW…
Browse files Browse the repository at this point in the history
…ithIDSig` (pingcap#12839)
  • Loading branch information
tangwz authored and ngaut committed Nov 5, 2019
1 parent 9ada79a commit 622e8aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions expression/builtin_info_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,21 @@ func (b *builtinLastInsertIDSig) vecEvalInt(input *chunk.Chunk, result *chunk.Co
}

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

func (b *builtinLastInsertIDWithIDSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
return err
}
i64s := result.Int64s()
for i := len(i64s) - 1; i >= 0; i-- {
if !result.IsNull(i) {
b.ctx.GetSessionVars().SetLastInsertID(uint64(i64s[i]))
break
}
}
return nil
}

func (b *builtinVersionSig) vectorized() bool {
Expand Down
1 change: 1 addition & 0 deletions expression/builtin_info_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var vecBuiltinInfoCases = map[string][]vecExprBenchCase{
ast.ConnectionID: {},
ast.LastInsertId: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{}},
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt}},
},
}

Expand Down

0 comments on commit 622e8aa

Please sign in to comment.