Skip to content

Commit

Permalink
expression: implement vectorized evaluation for 'builtinHourSi… (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
rogaps authored and zz-jason committed Oct 15, 2019
1 parent 5466a3c commit a4d8220
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,31 @@ func (b *builtinDateFormatSig) vecEvalString(input *chunk.Chunk, result *chunk.C
}

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

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

result.ResizeInt64(n, false)
result.MergeNulls(buf)
i64s := result.Int64s()
ds := buf.GoDurations()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
i64s[i] = int64(ds[i].Hours())
}
return nil
}

func (b *builtinAddDateDurationRealSig) vectorized() bool {
Expand Down
4 changes: 3 additions & 1 deletion expression/builtin_time_vec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
ast.DateDiff: {},
ast.TimeDiff: {},
ast.DateFormat: {},
ast.Hour: {},
ast.Hour: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{&rangeDurationGener{0.2}}},
},
ast.Minute: {},
ast.Second: {},
ast.MicroSecond: {},
Expand Down

0 comments on commit a4d8220

Please sign in to comment.