tidb builtin_string_vec_generated 源码

  • 2022-09-19
  • 浏览 (385)

tidb builtin_string_vec_generated 代码

文件路径:/expression/builtin_string_vec_generated.go

// Copyright 2021 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 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/tidb/util/chunk"
)

// vecEvalInt evals FIELD(str,str1,str2,str3,...).
// See https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_field
func (b *builtinFieldIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
	n := input.NumRows()
	buf0, err := b.bufAllocator.get()
	if err != nil {
		return err
	}
	defer b.bufAllocator.put(buf0)
	if err := b.args[0].VecEvalInt(b.ctx, input, buf0); err != nil {
		return err
	}
	buf1, err := b.bufAllocator.get()
	if err != nil {
		return err
	}
	defer b.bufAllocator.put(buf1)

	arg0 := buf0.Int64s()

	result.ResizeInt64(n, false)
	i64s := result.Int64s()
	for i := 0; i < n; i++ {
		i64s[i] = 0
	}
	for i := 1; i < len(b.args); i++ {
		if err := b.args[i].VecEvalInt(b.ctx, input, buf1); err != nil {
			return err
		}

		arg1 := buf1.Int64s()

		for j := 0; j < n; j++ {
			if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) {
				continue
			}

			if arg0[j] == arg1[j] {

				i64s[j] = int64(i)
			}
		}
	}
	return nil
}

func (b *builtinFieldIntSig) vectorized() bool {
	return true
}

// vecEvalInt evals FIELD(str,str1,str2,str3,...).
// See https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_field
func (b *builtinFieldRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
	n := input.NumRows()
	buf0, err := b.bufAllocator.get()
	if err != nil {
		return err
	}
	defer b.bufAllocator.put(buf0)
	if err := b.args[0].VecEvalReal(b.ctx, input, buf0); err != nil {
		return err
	}
	buf1, err := b.bufAllocator.get()
	if err != nil {
		return err
	}
	defer b.bufAllocator.put(buf1)

	arg0 := buf0.Float64s()

	result.ResizeInt64(n, false)
	i64s := result.Int64s()
	for i := 0; i < n; i++ {
		i64s[i] = 0
	}
	for i := 1; i < len(b.args); i++ {
		if err := b.args[i].VecEvalReal(b.ctx, input, buf1); err != nil {
			return err
		}

		arg1 := buf1.Float64s()

		for j := 0; j < n; j++ {
			if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) {
				continue
			}

			if arg0[j] == arg1[j] {

				i64s[j] = int64(i)
			}
		}
	}
	return nil
}

func (b *builtinFieldRealSig) vectorized() bool {
	return true
}

// vecEvalInt evals FIELD(str,str1,str2,str3,...).
// See https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_field
func (b *builtinFieldStringSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) error {
	n := input.NumRows()
	buf0, err := b.bufAllocator.get()
	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()
	if err != nil {
		return err
	}
	defer b.bufAllocator.put(buf1)

	result.ResizeInt64(n, false)
	i64s := result.Int64s()
	for i := 0; i < n; i++ {
		i64s[i] = 0
	}
	for i := 1; i < len(b.args); i++ {
		if err := b.args[i].VecEvalString(b.ctx, input, buf1); err != nil {
			return err
		}

		for j := 0; j < n; j++ {
			if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) {
				continue
			}

			if b.ctor.Compare(buf0.GetString(j), buf1.GetString(j)) == 0 {

				i64s[j] = int64(i)
			}
		}
	}
	return nil
}

func (b *builtinFieldStringSig) vectorized() bool {
	return true
}

相关信息

tidb 源码目录

相关文章

tidb builtin 源码

tidb builtin_arithmetic 源码

tidb builtin_arithmetic_vec 源码

tidb builtin_cast 源码

tidb builtin_cast_vec 源码

tidb builtin_compare 源码

tidb builtin_compare_vec 源码

tidb builtin_compare_vec_generated 源码

tidb builtin_control 源码

tidb builtin_control_vec_generated 源码

0  赞