github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_op_vec.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package memex
    15  
    16  import (
    17  	"fmt"
    18  	"math"
    19  
    20  	"github.com/whtcorpsinc/BerolinaSQL/allegrosql"
    21  	"github.com/whtcorpsinc/milevadb/types"
    22  	"github.com/whtcorpsinc/milevadb/soliton/chunk"
    23  )
    24  
    25  func (b *builtinTimeIsNullSig) vectorized() bool {
    26  	return true
    27  }
    28  
    29  func (b *builtinTimeIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
    30  	numEvents := input.NumEvents()
    31  	buf, err := b.bufSlabPredictor.get(types.ETDatetime, numEvents)
    32  	if err != nil {
    33  		return err
    34  	}
    35  	defer b.bufSlabPredictor.put(buf)
    36  
    37  	if err := b.args[0].VecEvalTime(b.ctx, input, buf); err != nil {
    38  		return err
    39  	}
    40  
    41  	result.ResizeInt64(numEvents, false)
    42  	i64s := result.Int64s()
    43  	for i := 0; i < numEvents; i++ {
    44  		if buf.IsNull(i) {
    45  			i64s[i] = 1
    46  		} else {
    47  			i64s[i] = 0
    48  		}
    49  	}
    50  	return nil
    51  }
    52  
    53  func (b *builtinLogicOrSig) vectorized() bool {
    54  	return true
    55  }
    56  
    57  func (b *builtinLogicOrSig) fallbackEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
    58  	n := input.NumEvents()
    59  	result.ResizeInt64(n, false)
    60  	x := result.Int64s()
    61  	for i := 0; i < n; i++ {
    62  		res, isNull, err := b.evalInt(input.GetEvent(i))
    63  		if err != nil {
    64  			return err
    65  		}
    66  		result.SetNull(i, isNull)
    67  		if isNull {
    68  			continue
    69  		}
    70  		x[i] = res
    71  	}
    72  	return nil
    73  }
    74  
    75  func (b *builtinLogicOrSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
    76  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
    77  		return err
    78  	}
    79  
    80  	n := input.NumEvents()
    81  	buf, err := b.bufSlabPredictor.get(types.ETInt, n)
    82  	if err != nil {
    83  		return err
    84  	}
    85  	defer b.bufSlabPredictor.put(buf)
    86  
    87  	sc := b.ctx.GetStochastikVars().StmtCtx
    88  	beforeWarns := sc.WarningCount()
    89  	err = b.args[1].VecEvalInt(b.ctx, input, buf)
    90  	afterWarns := sc.WarningCount()
    91  	if err != nil || afterWarns > beforeWarns {
    92  		if afterWarns > beforeWarns {
    93  			sc.TruncateWarnings(int(beforeWarns))
    94  		}
    95  		return b.fallbackEvalInt(input, result)
    96  	}
    97  
    98  	i64s := result.Int64s()
    99  	arg1s := buf.Int64s()
   100  
   101  	for i := 0; i < n; i++ {
   102  		isNull0 := result.IsNull(i)
   103  		isNull1 := buf.IsNull(i)
   104  		// Because buf is used to causetstore the conversion of args[0] in place, it could
   105  		// be that args[0] is null and args[1] is nonzero, in which case the result
   106  		// is 1. In these cases, we need to clear the null bit mask of the corresponding
   107  		// event in result.
   108  		// See https://dev.allegrosql.com/doc/refman/5.7/en/logical-operators.html#operator_or
   109  		isNull := false
   110  		if (!isNull0 && i64s[i] != 0) || (!isNull1 && arg1s[i] != 0) {
   111  			i64s[i] = 1
   112  		} else if isNull0 || isNull1 {
   113  			isNull = true
   114  		} else {
   115  			i64s[i] = 0
   116  		}
   117  		if isNull != isNull0 {
   118  			result.SetNull(i, isNull)
   119  		}
   120  	}
   121  	return nil
   122  }
   123  
   124  func (b *builtinBitOrSig) vectorized() bool {
   125  	return true
   126  }
   127  
   128  func (b *builtinBitOrSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   129  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   130  		return err
   131  	}
   132  	numEvents := input.NumEvents()
   133  	buf, err := b.bufSlabPredictor.get(types.ETInt, numEvents)
   134  	if err != nil {
   135  		return err
   136  	}
   137  	defer b.bufSlabPredictor.put(buf)
   138  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   139  		return err
   140  	}
   141  	arg0s := result.Int64s()
   142  	arg1s := buf.Int64s()
   143  	result.MergeNulls(buf)
   144  	for i := 0; i < numEvents; i++ {
   145  		arg0s[i] |= arg1s[i]
   146  	}
   147  	return nil
   148  }
   149  
   150  func (b *builtinDecimalIsFalseSig) vectorized() bool {
   151  	return true
   152  }
   153  
   154  func (b *builtinDecimalIsFalseSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   155  	numEvents := input.NumEvents()
   156  
   157  	buf, err := b.bufSlabPredictor.get(types.ETDecimal, numEvents)
   158  	if err != nil {
   159  		return err
   160  	}
   161  	defer b.bufSlabPredictor.put(buf)
   162  	if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
   163  		return err
   164  	}
   165  
   166  	decs := buf.Decimals()
   167  	result.ResizeInt64(numEvents, false)
   168  	i64s := result.Int64s()
   169  
   170  	for i := 0; i < numEvents; i++ {
   171  		isNull := buf.IsNull(i)
   172  		if b.keepNull && isNull {
   173  			result.SetNull(i, true)
   174  			continue
   175  		}
   176  		if isNull || !decs[i].IsZero() {
   177  			i64s[i] = 0
   178  		} else {
   179  			i64s[i] = 1
   180  		}
   181  	}
   182  	return nil
   183  }
   184  
   185  func (b *builtinIntIsFalseSig) vectorized() bool {
   186  	return true
   187  }
   188  
   189  func (b *builtinIntIsFalseSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   190  	numEvents := input.NumEvents()
   191  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   192  		return err
   193  	}
   194  	i64s := result.Int64s()
   195  	for i := 0; i < numEvents; i++ {
   196  		isNull := result.IsNull(i)
   197  		if b.keepNull && isNull {
   198  			continue
   199  		}
   200  		if isNull {
   201  			i64s[i] = 0
   202  			result.SetNull(i, false)
   203  		} else if i64s[i] != 0 {
   204  			i64s[i] = 0
   205  		} else {
   206  			i64s[i] = 1
   207  		}
   208  	}
   209  	return nil
   210  }
   211  
   212  func (b *builtinUnaryMinusRealSig) vectorized() bool {
   213  	return true
   214  }
   215  
   216  func (b *builtinUnaryMinusRealSig) vecEvalReal(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   217  	var err error
   218  	if err = b.args[0].VecEvalReal(b.ctx, input, result); err != nil {
   219  		return err
   220  	}
   221  
   222  	n := input.NumEvents()
   223  	f64s := result.Float64s()
   224  	for i := 0; i < n; i++ {
   225  		f64s[i] = -f64s[i]
   226  	}
   227  	return nil
   228  }
   229  
   230  func (b *builtinBitNegSig) vectorized() bool {
   231  	return true
   232  }
   233  
   234  func (b *builtinBitNegSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   235  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   236  		return err
   237  	}
   238  	n := input.NumEvents()
   239  	args := result.Int64s()
   240  	for i := 0; i < n; i++ {
   241  		args[i] = ^args[i]
   242  	}
   243  	return nil
   244  }
   245  
   246  func (b *builtinUnaryMinusDecimalSig) vectorized() bool {
   247  	return true
   248  }
   249  
   250  func (b *builtinUnaryMinusDecimalSig) vecEvalDecimal(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   251  	if err := b.args[0].VecEvalDecimal(b.ctx, input, result); err != nil {
   252  		return err
   253  	}
   254  
   255  	n := input.NumEvents()
   256  	decs := result.Decimals()
   257  	for i := 0; i < n; i++ {
   258  		if result.IsNull(i) {
   259  			continue
   260  		}
   261  		decs[i] = *types.DecimalNeg(&decs[i])
   262  	}
   263  	return nil
   264  }
   265  
   266  func (b *builtinIntIsNullSig) vectorized() bool {
   267  	return true
   268  }
   269  
   270  func (b *builtinIntIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   271  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   272  		return err
   273  	}
   274  
   275  	i64s := result.Int64s()
   276  	for i := 0; i < len(i64s); i++ {
   277  		if result.IsNull(i) {
   278  			i64s[i] = 1
   279  			result.SetNull(i, false)
   280  		} else {
   281  			i64s[i] = 0
   282  		}
   283  	}
   284  	return nil
   285  }
   286  
   287  func (b *builtinRealIsNullSig) vectorized() bool {
   288  	return true
   289  }
   290  
   291  func (b *builtinRealIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   292  	numEvents := input.NumEvents()
   293  	buf, err := b.bufSlabPredictor.get(types.ETReal, numEvents)
   294  	if err != nil {
   295  		return err
   296  	}
   297  	defer b.bufSlabPredictor.put(buf)
   298  
   299  	if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
   300  		return err
   301  	}
   302  
   303  	result.ResizeInt64(numEvents, false)
   304  	i64s := result.Int64s()
   305  	for i := 0; i < numEvents; i++ {
   306  		if buf.IsNull(i) {
   307  			i64s[i] = 1
   308  		} else {
   309  			i64s[i] = 0
   310  		}
   311  	}
   312  	return nil
   313  }
   314  
   315  func (b *builtinUnaryNotRealSig) vectorized() bool {
   316  	return true
   317  }
   318  
   319  func (b *builtinUnaryNotRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   320  	n := input.NumEvents()
   321  	buf, err := b.bufSlabPredictor.get(types.ETReal, n)
   322  	if err != nil {
   323  		return err
   324  	}
   325  	defer b.bufSlabPredictor.put(buf)
   326  	if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
   327  		return err
   328  	}
   329  	f64s := buf.Float64s()
   330  
   331  	result.ResizeInt64(n, false)
   332  	result.MergeNulls(buf)
   333  	i64s := result.Int64s()
   334  	for i := 0; i < n; i++ {
   335  		if result.IsNull(i) {
   336  			continue
   337  		}
   338  		if f64s[i] == 0 {
   339  			i64s[i] = 1
   340  		} else {
   341  			i64s[i] = 0
   342  		}
   343  	}
   344  	return nil
   345  }
   346  
   347  func (b *builtinLogicAndSig) vectorized() bool {
   348  	return true
   349  }
   350  
   351  func (b *builtinLogicAndSig) fallbackEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   352  	n := input.NumEvents()
   353  	result.ResizeInt64(n, false)
   354  	x := result.Int64s()
   355  	for i := 0; i < n; i++ {
   356  		res, isNull, err := b.evalInt(input.GetEvent(i))
   357  		if err != nil {
   358  			return err
   359  		}
   360  		result.SetNull(i, isNull)
   361  		if isNull {
   362  			continue
   363  		}
   364  		x[i] = res
   365  	}
   366  	return nil
   367  }
   368  
   369  func (b *builtinLogicAndSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   370  	n := input.NumEvents()
   371  
   372  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   373  		return err
   374  	}
   375  
   376  	buf1, err := b.bufSlabPredictor.get(types.ETInt, n)
   377  	if err != nil {
   378  		return err
   379  	}
   380  	defer b.bufSlabPredictor.put(buf1)
   381  
   382  	sc := b.ctx.GetStochastikVars().StmtCtx
   383  	beforeWarns := sc.WarningCount()
   384  	err = b.args[1].VecEvalInt(b.ctx, input, buf1)
   385  	afterWarns := sc.WarningCount()
   386  	if err != nil || afterWarns > beforeWarns {
   387  		if afterWarns > beforeWarns {
   388  			sc.TruncateWarnings(int(beforeWarns))
   389  		}
   390  		return b.fallbackEvalInt(input, result)
   391  	}
   392  
   393  	i64s := result.Int64s()
   394  	arg1 := buf1.Int64s()
   395  
   396  	for i := 0; i < n; i++ {
   397  		isNull0 := result.IsNull(i)
   398  		if !isNull0 && i64s[i] == 0 {
   399  			result.SetNull(i, false)
   400  			continue
   401  		}
   402  
   403  		isNull1 := buf1.IsNull(i)
   404  		if !isNull1 && arg1[i] == 0 {
   405  			i64s[i] = 0
   406  			result.SetNull(i, false)
   407  			continue
   408  		}
   409  
   410  		if isNull0 || isNull1 {
   411  			result.SetNull(i, true)
   412  			continue
   413  		}
   414  
   415  		i64s[i] = 1
   416  	}
   417  
   418  	return nil
   419  }
   420  
   421  func (b *builtinBitXorSig) vectorized() bool {
   422  	return true
   423  }
   424  
   425  func (b *builtinBitXorSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   426  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   427  		return err
   428  	}
   429  	numEvents := input.NumEvents()
   430  	buf, err := b.bufSlabPredictor.get(types.ETInt, numEvents)
   431  	if err != nil {
   432  		return err
   433  	}
   434  	defer b.bufSlabPredictor.put(buf)
   435  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   436  		return err
   437  	}
   438  	arg0s := result.Int64s()
   439  	arg1s := buf.Int64s()
   440  	result.MergeNulls(buf)
   441  	for i := 0; i < numEvents; i++ {
   442  		arg0s[i] ^= arg1s[i]
   443  	}
   444  	return nil
   445  }
   446  
   447  func (b *builtinLogicXorSig) vectorized() bool {
   448  	return true
   449  }
   450  
   451  func (b *builtinLogicXorSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   452  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   453  		return err
   454  	}
   455  
   456  	n := input.NumEvents()
   457  	buf, err := b.bufSlabPredictor.get(types.ETInt, n)
   458  	if err != nil {
   459  		return err
   460  	}
   461  	defer b.bufSlabPredictor.put(buf)
   462  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   463  		return err
   464  	}
   465  
   466  	i64s := result.Int64s()
   467  	arg1s := buf.Int64s()
   468  	// Returns NULL if either operand is NULL.
   469  	// See https://dev.allegrosql.com/doc/refman/5.7/en/logical-operators.html#operator_xor
   470  	result.MergeNulls(buf)
   471  	for i := 0; i < n; i++ {
   472  		if result.IsNull(i) {
   473  			continue
   474  		}
   475  		arg0 := i64s[i]
   476  		arg1 := arg1s[i]
   477  		if (arg0 != 0 && arg1 != 0) || (arg0 == 0 && arg1 == 0) {
   478  			i64s[i] = 0
   479  		} else {
   480  			i64s[i] = 1
   481  		}
   482  	}
   483  	return nil
   484  }
   485  
   486  func (b *builtinBitAndSig) vectorized() bool {
   487  	return true
   488  }
   489  
   490  func (b *builtinBitAndSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   491  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   492  		return err
   493  	}
   494  	numEvents := input.NumEvents()
   495  	buf, err := b.bufSlabPredictor.get(types.ETInt, numEvents)
   496  	if err != nil {
   497  		return err
   498  	}
   499  	defer b.bufSlabPredictor.put(buf)
   500  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   501  		return err
   502  	}
   503  	arg0s := result.Int64s()
   504  	arg1s := buf.Int64s()
   505  	result.MergeNulls(buf)
   506  	for i := 0; i < numEvents; i++ {
   507  		arg0s[i] &= arg1s[i]
   508  	}
   509  	return nil
   510  }
   511  
   512  func (b *builtinRealIsFalseSig) vectorized() bool {
   513  	return true
   514  }
   515  
   516  func (b *builtinRealIsFalseSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   517  	numEvents := input.NumEvents()
   518  	buf, err := b.bufSlabPredictor.get(types.ETReal, numEvents)
   519  	if err != nil {
   520  		return err
   521  	}
   522  	defer b.bufSlabPredictor.put(buf)
   523  	if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
   524  		return err
   525  	}
   526  
   527  	result.ResizeInt64(numEvents, false)
   528  	i64s := result.Int64s()
   529  	bufF64s := buf.Float64s()
   530  	for i := 0; i < numEvents; i++ {
   531  		isNull := buf.IsNull(i)
   532  		if b.keepNull && isNull {
   533  			result.SetNull(i, true)
   534  			continue
   535  		}
   536  		if isNull || bufF64s[i] != 0 {
   537  			i64s[i] = 0
   538  		} else {
   539  			i64s[i] = 1
   540  		}
   541  	}
   542  	return nil
   543  }
   544  
   545  func (b *builtinUnaryMinusIntSig) vectorized() bool {
   546  	return true
   547  }
   548  
   549  func (b *builtinUnaryMinusIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   550  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   551  		return err
   552  	}
   553  	n := input.NumEvents()
   554  	args := result.Int64s()
   555  	if allegrosql.HasUnsignedFlag(b.args[0].GetType().Flag) {
   556  		for i := 0; i < n; i++ {
   557  			if result.IsNull(i) {
   558  				continue
   559  			}
   560  			if uint64(args[i]) > uint64(-math.MinInt64) {
   561  				return types.ErrOverflow.GenWithStackByArgs("BIGINT", fmt.Sprintf("-%v", uint64(args[i])))
   562  			}
   563  			args[i] = -args[i]
   564  		}
   565  	} else {
   566  		for i := 0; i < n; i++ {
   567  			if result.IsNull(i) {
   568  				continue
   569  			}
   570  			if args[i] == math.MinInt64 {
   571  				return types.ErrOverflow.GenWithStackByArgs("BIGINT", fmt.Sprintf("-%v", args[i]))
   572  			}
   573  			args[i] = -args[i]
   574  		}
   575  	}
   576  	return nil
   577  }
   578  
   579  func (b *builtinUnaryNotDecimalSig) vectorized() bool {
   580  	return true
   581  }
   582  
   583  func (b *builtinUnaryNotDecimalSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   584  	n := input.NumEvents()
   585  	buf, err := b.bufSlabPredictor.get(types.ETDecimal, n)
   586  	if err != nil {
   587  		return err
   588  	}
   589  	defer b.bufSlabPredictor.put(buf)
   590  	if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
   591  		return err
   592  	}
   593  	decs := buf.Decimals()
   594  
   595  	result.ResizeInt64(n, false)
   596  	result.MergeNulls(buf)
   597  	i64s := result.Int64s()
   598  	for i := 0; i < n; i++ {
   599  		if result.IsNull(i) {
   600  			continue
   601  		}
   602  		if decs[i].IsZero() {
   603  			i64s[i] = 1
   604  		} else {
   605  			i64s[i] = 0
   606  		}
   607  	}
   608  	return nil
   609  }
   610  
   611  func (b *builtinUnaryNotIntSig) vectorized() bool {
   612  	return true
   613  }
   614  
   615  func (b *builtinUnaryNotIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   616  	n := input.NumEvents()
   617  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   618  		return err
   619  	}
   620  
   621  	i64s := result.Int64s()
   622  	for i := 0; i < n; i++ {
   623  		if result.IsNull(i) {
   624  			continue
   625  		}
   626  		if i64s[i] == 0 {
   627  			i64s[i] = 1
   628  		} else {
   629  			i64s[i] = 0
   630  		}
   631  	}
   632  	return nil
   633  }
   634  
   635  func (b *builtinDecimalIsNullSig) vectorized() bool {
   636  	return true
   637  }
   638  
   639  func (b *builtinDecimalIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   640  	numEvents := input.NumEvents()
   641  	buf, err := b.bufSlabPredictor.get(types.ETDecimal, numEvents)
   642  	if err != nil {
   643  		return err
   644  	}
   645  	defer b.bufSlabPredictor.put(buf)
   646  
   647  	if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
   648  		return err
   649  	}
   650  
   651  	result.ResizeInt64(numEvents, false)
   652  	i64s := result.Int64s()
   653  	for i := 0; i < numEvents; i++ {
   654  		if buf.IsNull(i) {
   655  			i64s[i] = 1
   656  		} else {
   657  			i64s[i] = 0
   658  		}
   659  	}
   660  	return nil
   661  }
   662  
   663  func (b *builtinLeftShiftSig) vectorized() bool {
   664  	return true
   665  }
   666  
   667  func (b *builtinLeftShiftSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   668  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   669  		return err
   670  	}
   671  	numEvents := input.NumEvents()
   672  	buf, err := b.bufSlabPredictor.get(types.ETInt, numEvents)
   673  	if err != nil {
   674  		return err
   675  	}
   676  	defer b.bufSlabPredictor.put(buf)
   677  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   678  		return err
   679  	}
   680  	arg0s := result.Int64s()
   681  	arg1s := buf.Int64s()
   682  	result.MergeNulls(buf)
   683  	for i := 0; i < numEvents; i++ {
   684  		arg0s[i] = int64(uint64(arg0s[i]) << uint64(arg1s[i]))
   685  	}
   686  	return nil
   687  }
   688  
   689  func (b *builtinRightShiftSig) vectorized() bool {
   690  	return true
   691  }
   692  
   693  func (b *builtinRightShiftSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   694  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   695  		return err
   696  	}
   697  	numEvents := input.NumEvents()
   698  	buf, err := b.bufSlabPredictor.get(types.ETInt, numEvents)
   699  	if err != nil {
   700  		return err
   701  	}
   702  	defer b.bufSlabPredictor.put(buf)
   703  	if err := b.args[1].VecEvalInt(b.ctx, input, buf); err != nil {
   704  		return err
   705  	}
   706  	arg0s := result.Int64s()
   707  	arg1s := buf.Int64s()
   708  	result.MergeNulls(buf)
   709  	for i := 0; i < numEvents; i++ {
   710  		arg0s[i] = int64(uint64(arg0s[i]) >> uint64(arg1s[i]))
   711  	}
   712  	return nil
   713  }
   714  
   715  func (b *builtinRealIsTrueSig) vectorized() bool {
   716  	return true
   717  }
   718  
   719  func (b *builtinRealIsTrueSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   720  	numEvents := input.NumEvents()
   721  	buf, err := b.bufSlabPredictor.get(types.ETReal, numEvents)
   722  	if err != nil {
   723  		return err
   724  	}
   725  	defer b.bufSlabPredictor.put(buf)
   726  
   727  	if err := b.args[0].VecEvalReal(b.ctx, input, buf); err != nil {
   728  		return err
   729  	}
   730  	result.ResizeInt64(numEvents, false)
   731  	f64s := buf.Float64s()
   732  	i64s := result.Int64s()
   733  	for i := 0; i < numEvents; i++ {
   734  		isNull := buf.IsNull(i)
   735  		if b.keepNull && isNull {
   736  			result.SetNull(i, true)
   737  			continue
   738  		}
   739  		if isNull || f64s[i] == 0 {
   740  			i64s[i] = 0
   741  		} else {
   742  			i64s[i] = 1
   743  		}
   744  	}
   745  	return nil
   746  }
   747  
   748  func (b *builtinDecimalIsTrueSig) vectorized() bool {
   749  	return true
   750  }
   751  
   752  func (b *builtinDecimalIsTrueSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   753  	numEvents := input.NumEvents()
   754  	buf, err := b.bufSlabPredictor.get(types.ETDecimal, numEvents)
   755  	if err != nil {
   756  		return err
   757  	}
   758  	defer b.bufSlabPredictor.put(buf)
   759  	if err := b.args[0].VecEvalDecimal(b.ctx, input, buf); err != nil {
   760  		return err
   761  	}
   762  
   763  	decs := buf.Decimals()
   764  	result.ResizeInt64(numEvents, false)
   765  	i64s := result.Int64s()
   766  
   767  	for i := 0; i < numEvents; i++ {
   768  		isNull := buf.IsNull(i)
   769  		if b.keepNull && isNull {
   770  			result.SetNull(i, true)
   771  			continue
   772  		}
   773  		if isNull || decs[i].IsZero() {
   774  			i64s[i] = 0
   775  		} else {
   776  			i64s[i] = 1
   777  		}
   778  	}
   779  	return nil
   780  }
   781  
   782  func (b *builtinIntIsTrueSig) vectorized() bool {
   783  	return true
   784  }
   785  
   786  func (b *builtinIntIsTrueSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   787  	numEvents := input.NumEvents()
   788  	if err := b.args[0].VecEvalInt(b.ctx, input, result); err != nil {
   789  		return err
   790  	}
   791  	i64s := result.Int64s()
   792  	for i := 0; i < numEvents; i++ {
   793  		isNull := result.IsNull(i)
   794  		if b.keepNull && isNull {
   795  			continue
   796  		}
   797  		if isNull {
   798  			i64s[i] = 0
   799  			result.SetNull(i, false)
   800  		} else if i64s[i] != 0 {
   801  			i64s[i] = 1
   802  		}
   803  	}
   804  	return nil
   805  }
   806  
   807  func (b *builtinDurationIsNullSig) vectorized() bool {
   808  	return true
   809  }
   810  
   811  func (b *builtinDurationIsNullSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error {
   812  	numEvents := input.NumEvents()
   813  	buf, err := b.bufSlabPredictor.get(types.ETDuration, numEvents)
   814  	if err != nil {
   815  		return err
   816  	}
   817  	defer b.bufSlabPredictor.put(buf)
   818  
   819  	if err := b.args[0].VecEvalDuration(b.ctx, input, buf); err != nil {
   820  		return err
   821  	}
   822  
   823  	result.ResizeInt64(numEvents, false)
   824  	i64s := result.Int64s()
   825  	for i := 0; i < numEvents; i++ {
   826  		if buf.IsNull(i) {
   827  			i64s[i] = 1
   828  		} else {
   829  			i64s[i] = 0
   830  		}
   831  	}
   832  	return nil
   833  }