Files
tidb/expression/builtin_time_vec_generated.go

612 lines
12 KiB
Go

// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by go generate in expression/generator; DO NOT EDIT.
package expression
import (
"github.com/pingcap/parser/mysql"
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
)
func (b *builtinAddDatetimeAndDurationSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
return err
}
buf0 := result
buf1, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
return err
}
result.MergeNulls(buf1)
arg0s := buf0.Times()
arg1s := buf1.GoDurations()
resultSlice := result.Times()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := arg1s[i]
// calculate
output, err := arg0.Add(b.ctx.GetSessionVars().StmtCtx, types.Duration{Duration: arg1, Fsp: -1})
if err != nil {
return err
}
// commit result
resultSlice[i] = output
}
return nil
}
func (b *builtinAddDatetimeAndDurationSig) vectorized() bool {
return true
}
func (b *builtinAddDatetimeAndStringSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
if err := b.args[0].VecEvalTime(b.ctx, input, result); err != nil {
return err
}
buf0 := result
buf1, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
return err
}
result.MergeNulls(buf1)
arg0s := buf0.Times()
resultSlice := result.Times()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := buf1.GetString(i)
// calculate
if !isDuration(arg1) {
result.SetNull(i, true) // fixed: true
continue
}
sc := b.ctx.GetSessionVars().StmtCtx
arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.SetNull(i, true) // fixed: true
continue
}
return err
}
output, err := arg0.Add(sc, arg1Duration)
if err != nil {
return err
}
// commit result
resultSlice[i] = output
}
return nil
}
func (b *builtinAddDatetimeAndStringSig) vectorized() bool {
return true
}
func (b *builtinAddDurationAndDurationSig) vecEvalDuration(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
return err
}
buf0 := result
buf1, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
return err
}
result.MergeNulls(buf1)
arg0s := buf0.GoDurations()
arg1s := buf1.GoDurations()
resultSlice := result.GoDurations()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := arg1s[i]
// calculate
output, err := types.AddDuration(arg0, arg1)
if err != nil {
return err
}
// commit result
resultSlice[i] = output
}
return nil
}
func (b *builtinAddDurationAndDurationSig) vectorized() bool {
return true
}
func (b *builtinAddDurationAndStringSig) vecEvalDuration(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
if err := b.args[0].VecEvalDuration(b.ctx, input, result); err != nil {
return err
}
buf0 := result
buf1, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
return err
}
result.MergeNulls(buf1)
arg0s := buf0.GoDurations()
resultSlice := result.GoDurations()
for i := 0; i < n; i++ {
if result.IsNull(i) {
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := buf1.GetString(i)
// calculate
if !isDuration(arg1) {
result.SetNull(i, true) // fixed: true
continue
}
sc := b.ctx.GetSessionVars().StmtCtx
arg1Duration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.SetNull(i, true) // fixed: true
continue
}
return err
}
output, err := types.AddDuration(arg0, arg1Duration.Duration)
if err != nil {
return err
}
// commit result
resultSlice[i] = output
}
return nil
}
func (b *builtinAddDurationAndStringSig) vectorized() bool {
return true
}
func (b *builtinAddStringAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf0, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf0)
if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
return err
}
buf1, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
return err
}
result.ReserveString(n)
arg1s := buf1.GoDurations()
for i := 0; i < n; i++ {
if buf0.IsNull(i) || buf1.IsNull(i) {
result.AppendNull()
continue
}
// get arg0 & arg1
arg0 := buf0.GetString(i)
arg1 := arg1s[i]
// calculate
sc := b.ctx.GetSessionVars().StmtCtx
fsp1 := int8(b.args[1].GetType().Decimal)
arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
var output string
if isDuration(arg0) {
output, err = strDurationAddDuration(sc, arg0, arg1Duration)
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.AppendNull() // fixed: false
continue
}
return err
}
} else {
output, err = strDatetimeAddDuration(sc, arg0, arg1Duration)
if err != nil {
return err
}
}
// commit result
result.AppendString(output)
}
return nil
}
func (b *builtinAddStringAndDurationSig) vectorized() bool {
return true
}
func (b *builtinAddStringAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf0, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf0)
if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil {
return err
}
arg1Type := b.args[1].GetType()
if mysql.HasBinaryFlag(arg1Type.Flag) {
result.ReserveString(n)
for i := 0; i < n; i++ {
result.AppendNull()
}
return nil
}
buf1, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
return err
}
result.ReserveString(n)
for i := 0; i < n; i++ {
if buf0.IsNull(i) || buf1.IsNull(i) {
result.AppendNull()
continue
}
// get arg0 & arg1
arg0 := buf0.GetString(i)
arg1 := buf1.GetString(i)
// calculate
sc := b.ctx.GetSessionVars().StmtCtx
arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.AppendNull() // fixed: false
continue
}
return err
}
var output string
if isDuration(arg0) {
output, err = strDurationAddDuration(sc, arg0, arg1Duration)
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.AppendNull() // fixed: false
continue
}
return err
}
} else {
output, err = strDatetimeAddDuration(sc, arg0, arg1Duration)
if err != nil {
return err
}
}
// commit result
result.AppendString(output)
}
return nil
}
func (b *builtinAddStringAndStringSig) vectorized() bool {
return true
}
func (b *builtinAddDateAndDurationSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf0, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf0)
if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
return err
}
buf1, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalDuration(b.ctx, input, buf1); err != nil {
return err
}
result.ReserveString(n)
arg0s := buf0.GoDurations()
arg1s := buf1.GoDurations()
for i := 0; i < n; i++ {
if buf0.IsNull(i) || buf1.IsNull(i) {
result.AppendNull()
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := arg1s[i]
// calculate
fsp0 := int8(b.args[0].GetType().Decimal)
fsp1 := int8(b.args[1].GetType().Decimal)
arg1Duration := types.Duration{Duration: arg1, Fsp: fsp1}
sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Add(arg1Duration)
if err != nil {
return err
}
output := sum.String()
// commit result
result.AppendString(output)
}
return nil
}
func (b *builtinAddDateAndDurationSig) vectorized() bool {
return true
}
func (b *builtinAddDateAndStringSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
buf0, err := b.bufAllocator.get(types.ETDuration, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf0)
if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil {
return err
}
buf1, err := b.bufAllocator.get(types.ETString, n)
if err != nil {
return err
}
defer b.bufAllocator.put(buf1)
if err := b.args[1].VecEvalString(b.ctx, input, buf1); err != nil {
return err
}
result.ReserveString(n)
arg0s := buf0.GoDurations()
for i := 0; i < n; i++ {
if buf0.IsNull(i) || buf1.IsNull(i) {
result.AppendNull()
continue
}
// get arg0 & arg1
arg0 := arg0s[i]
arg1 := buf1.GetString(i)
// calculate
if !isDuration(arg1) {
result.AppendNull() // fixed: false
continue
}
sc := b.ctx.GetSessionVars().StmtCtx
arg1Duration, err := types.ParseDuration(sc, arg1, getFsp4TimeAddSub(arg1))
if err != nil {
if terror.ErrorEqual(err, types.ErrTruncatedWrongVal) {
sc.AppendWarning(err)
result.AppendNull() // fixed: false
continue
}
return err
}
fsp0 := int8(b.args[0].GetType().Decimal)
sum, err := types.Duration{Duration: arg0, Fsp: fsp0}.Add(arg1Duration)
if err != nil {
return err
}
output := sum.String()
// commit result
result.AppendString(output)
}
return nil
}
func (b *builtinAddDateAndStringSig) vectorized() bool {
return true
}
func (b *builtinAddTimeDateTimeNullSig) vecEvalTime(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
result.ResizeTime(n, true)
return nil
}
func (b *builtinAddTimeDateTimeNullSig) vectorized() bool {
return true
}
func (b *builtinAddTimeStringNullSig) vecEvalString(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
result.ReserveString(n)
for i := 0; i < n; i++ {
result.AppendNull()
}
return nil
}
func (b *builtinAddTimeStringNullSig) vectorized() bool {
return true
}
func (b *builtinAddTimeDurationNullSig) vecEvalDuration(input *chunk.Chunk, result *chunk.Column) error {
n := input.NumRows()
result.ResizeGoDuration(n, true)
return nil
}
func (b *builtinAddTimeDurationNullSig) vectorized() bool {
return true
}