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 builtinSysDateWithFspSig #13332

Merged
merged 18 commits into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1f947bf
expression: implement vectorized evaluation for builtinSysDateWithFspSig
ekalinin Nov 10, 2019
afa9cc8
expression: make SysDateWithFsp testable (use getStmtTimestamp)
ekalinin Nov 10, 2019
16f178b
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
eca1168
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
cebf054
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
719ded7
expression: builtinSysDateWithFspSig, fix after merge
ekalinin Nov 11, 2019
4a98198
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
16aaf36
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
8581bc1
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
942160a
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
79cbdd2
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
7d6dc39
expression: builtinSysDateWithFspSig, fix after merge
ekalinin Nov 11, 2019
4d0517a
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 11, 2019
602dafd
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 12, 2019
e39ff2d
Merge branch 'master' into vec-builtinSysDateWithFspSig
ekalinin Nov 15, 2019
89d0902
expression: use Now() again; add test
ekalinin Nov 15, 2019
faae22d
Merge branch 'master' into vec-builtinSysDateWithFspSig
sre-bot Nov 16, 2019
db84551
Merge branch 'master' into vec-builtinSysDateWithFspSig
qw4990 Nov 16, 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
6 changes: 5 additions & 1 deletion expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,11 @@ func (b *builtinSysDateWithFspSig) evalTime(row chunk.Row) (d types.Time, isNull
}

loc := b.ctx.GetSessionVars().Location()
now := time.Now().In(loc)
nowTs, err := getStmtTimestamp(b.ctx)
if err != nil {
return types.Time{}, true, err
}
now := nowTs.In(loc)
qw4990 marked this conversation as resolved.
Show resolved Hide resolved
result, err := convertTimeToMysqlTime(now, int8(fsp), types.ModeHalfEven)
if err != nil {
return types.Time{}, true, err
Expand Down
36 changes: 34 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,43 @@ func (b *builtinAddDateStringIntSig) vecEvalTime(input *chunk.Chunk, result *chu
}

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

func (b *builtinSysDateWithFspSig) 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
}

loc := b.ctx.GetSessionVars().Location()
nowTs, err := getStmtTimestamp(b.ctx)
if err != nil {
return err
}
now := nowTs.In(loc)

result.ResizeTime(n, false)
result.MergeNulls(buf)
times := result.Times()
ds := buf.Int64s()

for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
t, err := convertTimeToMysqlTime(now, int8(ds[i]), types.ModeHalfEven)
if err != nil {
return err
}
times[i] = t
}
return nil
}

func (b *builtinAddDateDurationIntSig) vectorized() bool {
Expand Down
4 changes: 4 additions & 0 deletions expression/builtin_time_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
geners: []dataGenerator{&timeStrGener{}, &constStrGener{"%y-%m-%d"}},
},
},
ast.Sysdate: {
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt},
geners: []dataGenerator{&rangeInt64Gener{begin: 0, end: 7}}},
},
ast.GetFormat: {
{
retEvalType: types.ETString,
Expand Down