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 builtinMakeDateSig #13305

Merged
merged 20 commits into from
Nov 11, 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
1f70627
expression: implement vectorized evaluation for builtinMakeDateSig
ekalinin Nov 8, 2019
1ff1b20
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
1497baf
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
29f975e
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
341752b
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
3726aaf
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
0d643dc
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 9, 2019
411fb65
expression: builtinMakeDateSig, fix err handle
ekalinin Nov 9, 2019
352b906
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 10, 2019
ae2def7
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
21d6202
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
d43e0aa
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
5ff9f54
expression: builtinMakeDateSig, fixes after review
ekalinin Nov 11, 2019
076d5a5
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
6aecb59
expression: builtinMakeDateSig, fixes after review
ekalinin Nov 11, 2019
870fccd
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
9d5813c
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
19e8909
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
2ec99df
Merge branch 'master' into vec-builtinMakeDateSig
ekalinin Nov 11, 2019
f039639
Merge branch 'master' into vec-builtinMakeDateSig
sre-bot Nov 11, 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
63 changes: 61 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,11 +1022,70 @@ func (b *builtinAddDateIntDecimalSig) vecEvalTime(input *chunk.Chunk, result *ch
}

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

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

buf2, err := b.bufAllocator.get(types.ETInt, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf2)
if err := b.args[1].VecEvalInt(b.ctx, input, buf2); err != nil {
return err
}

result.ResizeTime(n, false)
result.MergeNulls(buf1, buf2)

times := result.Times()
years := buf1.Int64s()
days := buf2.Int64s()

for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
if days[i] <= 0 || years[i] < 0 || years[i] > 9999 {
result.SetNull(i, true)
continue
}
if years[i] < 70 {
years[i] += 2000
} else if years[i] < 100 {
years[i] += 1900
}
startTime := types.Time{
Time: types.FromDate(int(years[i]), 1, 1, 0, 0, 0, 0),
Type: mysql.TypeDate,
Fsp: 0,
}
retTimestamp := types.TimestampDiff("DAY", types.ZeroDate, startTime)
if retTimestamp == 0 {
if err = handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(startTime.String())); err != nil {
return err
}
result.SetNull(i, true)
continue
}
ret := types.TimeFromDays(retTimestamp + days[i] - 1)
if ret.IsZero() || ret.Time.Year() > 9999 {
result.SetNull(i, true)
continue
}
times[i] = ret
}
return nil
}

func (b *builtinWeekOfYearSig) vectorized() bool {
Expand Down
6 changes: 5 additions & 1 deletion expression/builtin_time_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
ast.CurrentDate: {
{retEvalType: types.ETDatetime},
},
ast.MakeDate: {},
ast.MakeDate: {
{retEvalType: types.ETDatetime, childrenTypes: []types.EvalType{types.ETInt, types.ETInt},
geners: []dataGenerator{&rangeInt64Gener{0, 2200}, &rangeInt64Gener{0, 365}},
},
},
ast.MakeTime: {},
ast.PeriodAdd: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETInt, types.ETInt}, geners: []dataGenerator{new(periodGener), new(periodGener)}},
Expand Down