github.com/whtcorpsinc/milevadb-prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_string_vec_test.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 "math/rand" 18 "testing" 19 20 . "github.com/whtcorpsinc/check" 21 "github.com/whtcorpsinc/BerolinaSQL/ast" 22 "github.com/whtcorpsinc/BerolinaSQL/charset" 23 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 24 "github.com/whtcorpsinc/milevadb/types" 25 ) 26 27 type randSpaceStrGener struct { 28 lenBegin int 29 lenEnd int 30 } 31 32 func (g *randSpaceStrGener) gen() interface{} { 33 n := rand.Intn(g.lenEnd-g.lenBegin) + g.lenBegin 34 buf := make([]byte, n) 35 for i := range buf { 36 x := rand.Intn(150) 37 if x < 10 { 38 buf[i] = byte('0' + x) 39 } else if x-10 < 26 { 40 buf[i] = byte('a' + x - 10) 41 } else if x < 62 { 42 buf[i] = byte('A' + x - 10 - 26) 43 } else { 44 buf[i] = byte(' ') 45 } 46 } 47 return string(buf) 48 } 49 50 var vecBuiltinStringCases = map[string][]vecExprBenchCase{ 51 ast.Length: { 52 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newDefaultGener(0.2, types.ETString)}}, 53 }, 54 ast.ASCII: { 55 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newDefaultGener(0.2, types.ETString)}}, 56 }, 57 ast.Concat: { 58 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETString}}, 59 }, 60 ast.ConcatWS: { 61 { 62 retEvalType: types.ETString, 63 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETString, types.ETString}, 64 geners: []dataGenerator{&constStrGener{","}}, 65 }, 66 { 67 retEvalType: types.ETString, 68 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETString, types.ETString}, 69 geners: []dataGenerator{newDefaultGener(1, types.ETString)}, 70 }, 71 { 72 retEvalType: types.ETString, 73 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETString}, 74 geners: []dataGenerator{ 75 &constStrGener{"<------------------>"}, 76 &constStrGener{"1413006"}, 77 &constStrGener{"idlfmv"}, 78 }, 79 }, 80 }, 81 ast.Convert: { 82 { 83 retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 84 constants: []*Constant{nil, {Value: types.NewCauset("utf8"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 85 }, 86 { 87 retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 88 constants: []*Constant{nil, {Value: types.NewCauset("binary"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 89 }, 90 { 91 retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 92 constants: []*Constant{nil, {Value: types.NewCauset("utf8mb4"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 93 }, 94 { 95 retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 96 constants: []*Constant{nil, {Value: types.NewCauset("ascii"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 97 }, 98 { 99 retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 100 constants: []*Constant{nil, {Value: types.NewCauset("latin1"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 101 }, 102 }, 103 ast.Substring: { 104 { 105 retEvalType: types.ETString, 106 childrenTypes: []types.EvalType{types.ETString, types.ETInt}, 107 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(-25, 25)}, 108 }, 109 { 110 retEvalType: types.ETString, 111 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETInt}, 112 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(-25, 25), newRangeInt64Gener(-25, 25)}, 113 }, 114 { 115 retEvalType: types.ETString, 116 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETInt}, 117 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 118 {Tp: allegrosql.TypeLonglong}, {Tp: allegrosql.TypeLonglong}}, 119 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(-25, 25), newRangeInt64Gener(-25, 25)}, 120 }, 121 }, 122 ast.SubstringIndex: { 123 { 124 retEvalType: types.ETString, 125 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 126 geners: []dataGenerator{newRandLenStrGener(0, 20), newRandLenStrGener(0, 2), newRangeInt64Gener(-4, 4)}, 127 }, 128 }, 129 ast.Locate: { 130 { 131 retEvalType: types.ETInt, 132 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 133 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20)}, 134 }, 135 { 136 retEvalType: types.ETInt, 137 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 138 geners: []dataGenerator{newRandLenStrGener(1, 2), newRandLenStrGener(0, 20)}, 139 }, 140 { 141 retEvalType: types.ETInt, 142 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 143 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"})}, 144 }, 145 { 146 retEvalType: types.ETInt, 147 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 148 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20), newRangeInt64Gener(-10, 20)}, 149 }, 150 { 151 retEvalType: types.ETInt, 152 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 153 geners: []dataGenerator{newRandLenStrGener(1, 2), newRandLenStrGener(0, 10), newRangeInt64Gener(0, 8)}, 154 }, 155 { 156 retEvalType: types.ETInt, 157 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 158 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"})}, 159 }, 160 { 161 retEvalType: types.ETInt, 162 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 163 childrenFieldTypes: []*types.FieldType{nil, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 164 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20)}, 165 }, 166 { 167 retEvalType: types.ETInt, 168 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 169 childrenFieldTypes: []*types.FieldType{nil, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 170 geners: []dataGenerator{newRandLenStrGener(1, 2), newRandLenStrGener(0, 20)}, 171 }, 172 { 173 retEvalType: types.ETInt, 174 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 175 childrenFieldTypes: []*types.FieldType{nil, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 176 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"})}, 177 }, 178 { 179 retEvalType: types.ETInt, 180 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 181 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, nil}, 182 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20)}, 183 }, 184 { 185 retEvalType: types.ETInt, 186 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 187 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, nil}, 188 geners: []dataGenerator{newRandLenStrGener(1, 2), newRandLenStrGener(0, 20)}, 189 }, 190 { 191 retEvalType: types.ETInt, 192 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 193 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, nil}, 194 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"})}, 195 }, 196 { 197 retEvalType: types.ETInt, 198 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 199 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 200 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20)}, 201 }, 202 { 203 retEvalType: types.ETInt, 204 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 205 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 206 geners: []dataGenerator{newRandLenStrGener(1, 2), newRandLenStrGener(0, 20)}, 207 }, 208 { 209 retEvalType: types.ETInt, 210 childrenTypes: []types.EvalType{types.ETString, types.ETString}, 211 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 212 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"})}, 213 }, 214 { 215 retEvalType: types.ETInt, 216 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 217 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeInt24}}, 218 geners: []dataGenerator{newRandLenStrGener(0, 10), newRandLenStrGener(0, 20), newRangeInt64Gener(-10, 20)}, 219 }, 220 { 221 retEvalType: types.ETInt, 222 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 223 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, {Tp: allegrosql.TypeInt24}}, 224 geners: []dataGenerator{newSelectStringGener([]string{"01", "10", "001", "110", "0001", "1110"}), newSelectStringGener([]string{"010010001000010", "101101110111101"}), newRangeInt64Gener(-10, 20)}, 225 }, 226 }, 227 ast.Hex: { 228 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandHexStrGener(10, 100)}}, 229 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}}, 230 }, 231 ast.Unhex: { 232 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandHexStrGener(10, 100)}}, 233 }, 234 ast.Trim: { 235 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randSpaceStrGener{10, 100}}}, 236 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 20), newRandLenStrGener(5, 25)}}, 237 { 238 retEvalType: types.ETString, 239 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 240 geners: []dataGenerator{newRandLenStrGener(10, 20), newRandLenStrGener(5, 25), nil}, 241 constants: []*Constant{nil, nil, {Value: types.NewCauset(ast.TrimBoth), RetType: types.NewFieldType(allegrosql.TypeLonglong)}}, 242 }, 243 { 244 retEvalType: types.ETString, 245 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 246 geners: []dataGenerator{newRandLenStrGener(10, 20), newRandLenStrGener(5, 25), nil}, 247 constants: []*Constant{nil, nil, {Value: types.NewCauset(ast.TrimLeading), RetType: types.NewFieldType(allegrosql.TypeLonglong)}}, 248 }, 249 { 250 retEvalType: types.ETString, 251 childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETInt}, 252 geners: []dataGenerator{newRandLenStrGener(10, 20), newRandLenStrGener(5, 25), nil}, 253 constants: []*Constant{nil, nil, {Value: types.NewCauset(ast.TrimTrailing), RetType: types.NewFieldType(allegrosql.TypeLonglong)}}, 254 }, 255 }, 256 ast.LTrim: { 257 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randSpaceStrGener{10, 100}}}, 258 }, 259 ast.RTrim: { 260 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&randSpaceStrGener{10, 100}}}, 261 }, 262 ast.Lpad: { 263 { 264 retEvalType: types.ETString, 265 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 266 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(168435456, 368435456), newRandLenStrGener(0, 10)}, 267 }, 268 { 269 retEvalType: types.ETString, 270 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 271 geners: []dataGenerator{newDefaultGener(0.2, types.ETString), newDefaultGener(0.2, types.ETInt), newDefaultGener(0.2, types.ETString)}, 272 }, 273 { 274 retEvalType: types.ETString, 275 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 276 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 277 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(168435456, 368435456), newRandLenStrGener(0, 10)}, 278 }, 279 { 280 retEvalType: types.ETString, 281 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 282 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 283 geners: []dataGenerator{newDefaultGener(0.2, types.ETString), newDefaultGener(0.2, types.ETInt), newDefaultGener(0.2, types.ETString)}, 284 }, 285 }, 286 ast.Rpad: { 287 { 288 retEvalType: types.ETString, 289 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 290 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(168435456, 368435456), newRandLenStrGener(0, 10)}, 291 }, 292 { 293 retEvalType: types.ETString, 294 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 295 geners: []dataGenerator{newDefaultGener(0.2, types.ETString), newDefaultGener(0.2, types.ETInt), newDefaultGener(0.2, types.ETString)}, 296 }, 297 { 298 retEvalType: types.ETString, 299 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 300 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 301 geners: []dataGenerator{newRandLenStrGener(0, 20), newRangeInt64Gener(168435456, 368435456), newRandLenStrGener(0, 10)}, 302 }, 303 { 304 retEvalType: types.ETString, 305 childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETString}, 306 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 307 geners: []dataGenerator{newDefaultGener(0.2, types.ETString), newDefaultGener(0.2, types.ETInt), newDefaultGener(0.2, types.ETString)}, 308 }, 309 }, 310 ast.CharLength: { 311 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}}, 312 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}, 313 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 314 }, 315 }, 316 ast.BitLength: { 317 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}}, 318 }, 319 ast.CharFunc: { 320 { 321 retEvalType: types.ETString, 322 childrenTypes: []types.EvalType{types.ETInt, types.ETInt, types.ETInt, types.ETString}, 323 geners: []dataGenerator{&charInt64Gener{}, &charInt64Gener{}, &charInt64Gener{}, nil}, 324 constants: []*Constant{nil, nil, nil, {Value: types.NewCauset("ascii"), RetType: types.NewFieldType(allegrosql.TypeString)}}, 325 }, 326 }, 327 ast.FindInSet: { 328 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}}, 329 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{&constStrGener{"case"}, &constStrGener{"test,case"}}}, 330 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{&constStrGener{""}, &constStrGener{"test,case"}}}, 331 }, 332 ast.MakeSet: { 333 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt, types.ETString, types.ETString, types.ETString, types.ETString, types.ETString, types.ETString, types.ETString, types.ETString}}, 334 }, 335 ast.Oct: { 336 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}}, 337 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{&numStrGener{*newRangeInt64Gener(-10, 10)}}}, 338 }, 339 ast.Quote: { 340 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}}, 341 }, 342 ast.Ord: { 343 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}}, 344 }, 345 ast.Bin: { 346 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}}, 347 }, 348 ast.ToBase64: { 349 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandLenStrGener(0, 10)}}, 350 }, 351 ast.FromBase64: { 352 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 100)}}, 353 }, 354 ast.ExportSet: { 355 { 356 retEvalType: types.ETString, 357 childrenTypes: []types.EvalType{types.ETInt, types.ETString, types.ETString}, 358 geners: []dataGenerator{newRangeInt64Gener(10, 100), &constStrGener{"Y"}, &constStrGener{"N"}}, 359 }, 360 { 361 retEvalType: types.ETString, 362 childrenTypes: []types.EvalType{types.ETInt, types.ETString, types.ETString, types.ETString}, 363 geners: []dataGenerator{newRangeInt64Gener(10, 100), &constStrGener{"Y"}, &constStrGener{"N"}, &constStrGener{","}}, 364 }, 365 { 366 retEvalType: types.ETString, 367 childrenTypes: []types.EvalType{types.ETInt, types.ETString, types.ETString, types.ETString, types.ETInt}, 368 geners: []dataGenerator{newRangeInt64Gener(10, 100), &constStrGener{"Y"}, &constStrGener{"N"}, &constStrGener{","}, newRangeInt64Gener(-10, 70)}, 369 }, 370 }, 371 ast.Repeat: { 372 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt}, geners: []dataGenerator{newRandLenStrGener(10, 20), newRangeInt64Gener(-10, 10)}}, 373 }, 374 ast.Lower: { 375 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}}, 376 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newSelectStringGener([]string{"one week’s time TEST", "one week's time TEST", "ABC测试DEF", "ABCテストABC"})}}, 377 }, 378 ast.IsNull: { 379 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 20)}}, 380 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newDefaultGener(0.2, types.ETString)}}, 381 }, 382 ast.Upper: { 383 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}}, 384 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newSelectStringGener([]string{"one week’s time TEST", "one week's time TEST", "abc测试DeF", "AbCテストAbC"})}}, 385 }, 386 ast.Right: { 387 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt}}, 388 // need to add BinaryFlag for the Binary func 389 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt}, 390 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 391 {Tp: allegrosql.TypeLonglong}}, 392 geners: []dataGenerator{ 393 newRandLenStrGener(10, 20), 394 newRangeInt64Gener(-10, 20), 395 }, 396 }, 397 }, 398 ast.Left: { 399 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt}}, 400 // need to add BinaryFlag for the Binary func 401 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt}, 402 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 403 {Tp: allegrosql.TypeLonglong}}, 404 geners: []dataGenerator{ 405 newRandLenStrGener(10, 20), 406 newRangeInt64Gener(-10, 20), 407 }, 408 }, 409 }, 410 ast.Space: { 411 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{newRangeInt64Gener(-10, 2000)}}, 412 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt}, geners: []dataGenerator{newRangeInt64Gener(5, 10)}}, 413 }, 414 ast.Reverse: { 415 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 20)}}, 416 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, geners: []dataGenerator{newDefaultGener(0.2, types.ETString)}}, 417 // need to add BinaryFlag for the Binary func 418 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString}, 419 childrenFieldTypes: []*types.FieldType{{Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}}, 420 }, 421 }, 422 ast.Instr: { 423 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}}, 424 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{&constStrGener{"test,case"}, &constStrGener{"case"}}}, 425 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{&constStrGener{"test,case"}, &constStrGener{"testcase"}}}, 426 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 427 childrenFieldTypes: []*types.FieldType{ 428 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 429 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 430 }, 431 }, 432 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 433 childrenFieldTypes: []*types.FieldType{ 434 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 435 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 436 }, 437 geners: []dataGenerator{&constStrGener{"test,case"}, &constStrGener{"case"}}, 438 }, 439 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, 440 childrenFieldTypes: []*types.FieldType{ 441 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 442 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 443 }, 444 geners: []dataGenerator{&constStrGener{"test,case"}, &constStrGener{""}}, 445 }, 446 }, 447 ast.Replace: { 448 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString, types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 20), newRandLenStrGener(0, 10), newRandLenStrGener(0, 10)}}, 449 }, 450 ast.InsertFunc: { 451 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETInt, types.ETString}, geners: []dataGenerator{newRandLenStrGener(10, 20), newRangeInt64Gener(-10, 20), newRangeInt64Gener(0, 100), newRandLenStrGener(0, 10)}}, 452 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETInt, types.ETInt, types.ETString}, 453 childrenFieldTypes: []*types.FieldType{ 454 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 455 {Tp: allegrosql.TypeLonglong}, 456 {Tp: allegrosql.TypeLonglong}, 457 {Tp: allegrosql.TypeString, Flag: allegrosql.BinaryFlag, DefCauslate: charset.DefCauslationBin}, 458 }, 459 }, 460 }, 461 ast.Elt: { 462 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETInt, types.ETString, types.ETString, types.ETString}, geners: []dataGenerator{newRangeInt64Gener(-1, 5)}}, 463 }, 464 ast.FromUnixTime: { 465 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDecimal, types.ETString}, 466 geners: []dataGenerator{ 467 gener{*newDefaultGener(0.9, types.ETDecimal)}, 468 &constStrGener{"%y-%m-%d"}, 469 }, 470 }, 471 }, 472 ast.Strcmp: { 473 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}}, 474 {retEvalType: types.ETInt, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{ 475 newSelectStringGener( 476 []string{ 477 "test", 478 }, 479 ), 480 newSelectStringGener( 481 []string{ 482 "test", 483 }, 484 ), 485 }}, 486 }, 487 ast.Format: { 488 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDecimal, types.ETInt}, geners: []dataGenerator{ 489 newRangeDecimalGener(-10000, 10000, 0), 490 newRangeInt64Gener(-10, 40), 491 }}, 492 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETReal, types.ETInt}, geners: []dataGenerator{ 493 newRangeRealGener(-10000, 10000, 0), 494 newRangeInt64Gener(-10, 40), 495 }}, 496 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDecimal, types.ETInt}, geners: []dataGenerator{ 497 newRangeDecimalGener(-10000, 10000, 1), 498 newRangeInt64Gener(-10, 40), 499 }}, 500 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETReal, types.ETInt}, geners: []dataGenerator{ 501 newRangeRealGener(-10000, 10000, 1), 502 newRangeInt64Gener(-10, 40), 503 }}, 504 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETString, types.ETString}, geners: []dataGenerator{ 505 newRealStringGener(), 506 &numStrGener{*newRangeInt64Gener(-10, 40)}, 507 }}, 508 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETDecimal, types.ETInt, types.ETString}, geners: []dataGenerator{ 509 newRangeDecimalGener(-10000, 10000, 0.5), 510 newRangeInt64Gener(-10, 40), 511 newNullWrappedGener(0.1, &constStrGener{"en_US"}), 512 }}, 513 {retEvalType: types.ETString, childrenTypes: []types.EvalType{types.ETReal, types.ETInt, types.ETString}, geners: []dataGenerator{ 514 newRangeRealGener(-10000, 10000, 0.5), 515 newRangeInt64Gener(-10, 40), 516 newNullWrappedGener(0.1, &constStrGener{"en_US"}), 517 }}, 518 }, 519 } 520 521 func (s *testVectorizeSuite1) TestVectorizedBuiltinStringEvalOneVec(c *C) { 522 testVectorizedEvalOneVec(c, vecBuiltinStringCases) 523 } 524 525 func (s *testVectorizeSuite1) TestVectorizedBuiltinStringFunc(c *C) { 526 testVectorizedBuiltinFunc(c, vecBuiltinStringCases) 527 } 528 529 func BenchmarkVectorizedBuiltinStringEvalOneVec(b *testing.B) { 530 benchmarkVectorizedEvalOneVec(b, vecBuiltinStringCases) 531 } 532 533 func BenchmarkVectorizedBuiltinStringFunc(b *testing.B) { 534 benchmarkVectorizedBuiltinFunc(b, vecBuiltinStringCases) 535 }