Skip to content

Commit

Permalink
expression: implement vectorized evaluation for builtinSecondSig (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdong-d authored and XiaTianliang committed Dec 21, 2019
1 parent e000a35 commit 103f135
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
23 changes: 21 additions & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,30 @@ func (b *builtinMinuteSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column)
}

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

func (b *builtinSecondSig) 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()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
i64s[i] = int64(buf.GetDuration(i, int(types.UnspecifiedFsp)).Second())
}
return nil
}

func (b *builtinNowWithoutArgSig) 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 @@ -35,7 +35,9 @@ var vecBuiltinTimeCases = map[string][]vecExprBenchCase{
ast.Minute: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{&rangeDurationGener{0.2}}},
},
ast.Second: {},
ast.Second: {
{retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETDuration}, geners: []dataGenerator{&rangeDurationGener{0.2}}},
},
ast.MicroSecond: {},
ast.Now: {},
ast.DayOfWeek: {},
Expand Down

0 comments on commit 103f135

Please sign in to comment.