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: implement vectorized evaluation for builtinCastIntAsTimeSig #12842

Merged
merged 20 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
db01861
expression: implement vectorized evaluation for builtinCastIntAsTimeSig
ekalinin Oct 20, 2019
2b46664
expression: improved builtinCastIntAsTimeSig
ekalinin Oct 20, 2019
a2e362b
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
7c060bd
Update expression/builtin_cast_vec.go
ekalinin Oct 21, 2019
3d23c7a
Update expression/builtin_cast_vec.go
ekalinin Oct 21, 2019
d66846e
expression: improved builtinCastIntAsTimeSig (fsp)
ekalinin Oct 21, 2019
bf79b20
Update expression/builtin_cast_vec.go
ekalinin Oct 21, 2019
125fbb1
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
456cd2c
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
d321ee7
Update builtin_cast_vec.go
ekalinin Oct 21, 2019
5d328b9
expression: improved builtinCastIntAsTimeSig (tests)
ekalinin Oct 21, 2019
25804fa
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
9912320
expression: improved builtinCastIntAsTimeSig (lint)
ekalinin Oct 21, 2019
3910ee1
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
830c010
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
d4c7978
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 21, 2019
6600256
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 22, 2019
77f4a1e
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 22, 2019
d52cdff
Merge branch 'master' into vec-builtinCastIntAsTimeSig
ekalinin Oct 22, 2019
8d0b8ea
Merge branch 'master' into vec-builtinCastIntAsTimeSig
sre-bot Oct 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,45 @@ func (b *builtinCastDurationAsIntSig) vecEvalInt(input *chunk.Chunk, result *chu
}

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

func (b *builtinCastIntAsTimeSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
return errors.Errorf("not implemented")
n := input.NumRows()
buf, err := b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf)
if err := b.args[0].VecEvalInt(b.ctx, input, buf); err != nil {
return err
}

result.ResizeTime(n, false)
result.MergeNulls(buf)
times := result.Times()
i64s := buf.Int64s()
stmt := b.ctx.GetSessionVars().StmtCtx
fsp := int8(b.tp.Decimal)
for i := 0; i < n; i++ {
if buf.IsNull(i) {
continue
}
tm, err := types.ParseTimeFromNum(stmt, i64s[i], b.tp.Tp, fsp)
if err != nil {
if err = handleInvalidTimeError(b.ctx, err); err != nil {
return err
}
result.SetNull(i, true)
continue
}
times[i] = tm
if b.tp.Tp == mysql.TypeDate {
// Truncate hh:mm:ss part if the type is Date.
times[i].Time = types.FromDate(tm.Time.Year(), tm.Time.Month(), tm.Time.Day(), 0, 0, 0, 0)
}
}
return nil
}

func (b *builtinCastRealAsJSONSig) vectorized() bool {
Expand Down
1 change: 1 addition & 0 deletions expression/builtin_cast_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ var vecBuiltinCastCases = map[string][]vecExprBenchCase{
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETJson}},
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&jsonStringGener{}}},
{retEvalType: types.ETJson, childrenTypes: []types.EvalType{types.ETDecimal}},
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt}},
},
}

Expand Down