github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_other_vec_generated.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 // Code generated by go generate in memex/generator; DO NOT EDIT. 15 16 package memex 17 18 import ( 19 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 20 "github.com/whtcorpsinc/milevadb/types" 21 "github.com/whtcorpsinc/milevadb/types/json" 22 "github.com/whtcorpsinc/milevadb/soliton/chunk" 23 "github.com/whtcorpsinc/milevadb/soliton/defCauslate" 24 ) 25 26 func (b *builtinInIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 27 n := input.NumEvents() 28 buf0, err := b.bufSlabPredictor.get(types.ETInt, n) 29 if err != nil { 30 return err 31 } 32 defer b.bufSlabPredictor.put(buf0) 33 if err := b.args[0].VecEvalInt(b.ctx, input, buf0); err != nil { 34 return err 35 } 36 buf1, err := b.bufSlabPredictor.get(types.ETInt, n) 37 if err != nil { 38 return err 39 } 40 defer b.bufSlabPredictor.put(buf1) 41 42 args0 := buf0.Int64s() 43 result.ResizeInt64(n, true) 44 r64s := result.Int64s() 45 for i := 0; i < n; i++ { 46 r64s[i] = 0 47 } 48 hasNull := make([]bool, n) 49 if b.hasNull { 50 for i := 0; i < n; i++ { 51 hasNull[i] = true 52 } 53 } 54 isUnsigned0 := allegrosql.HasUnsignedFlag(b.args[0].GetType().Flag) 55 var compareResult int 56 args := b.args 57 if len(b.hashSet) != 0 { 58 args = b.nonConstArgs 59 for i := 0; i < n; i++ { 60 if buf0.IsNull(i) { 61 hasNull[i] = true 62 continue 63 } 64 arg0 := args0[i] 65 if isUnsigned, ok := b.hashSet[arg0]; ok { 66 if (isUnsigned0 && isUnsigned) || (!isUnsigned0 && !isUnsigned) { 67 r64s[i] = 1 68 result.SetNull(i, false) 69 } 70 if arg0 >= 0 { 71 r64s[i] = 1 72 result.SetNull(i, false) 73 } 74 } 75 } 76 } 77 78 for j := 1; j < len(args); j++ { 79 if err := args[j].VecEvalInt(b.ctx, input, buf1); err != nil { 80 return err 81 } 82 isUnsigned := allegrosql.HasUnsignedFlag(args[j].GetType().Flag) 83 args1 := buf1.Int64s() 84 buf1.MergeNulls(buf0) 85 for i := 0; i < n; i++ { 86 if r64s[i] != 0 { 87 continue 88 } 89 if buf1.IsNull(i) { 90 hasNull[i] = true 91 continue 92 } 93 arg0 := args0[i] 94 arg1 := args1[i] 95 compareResult = 1 96 switch { 97 case (isUnsigned0 && isUnsigned), (!isUnsigned0 && !isUnsigned): 98 if arg1 == arg0 { 99 compareResult = 0 100 } 101 case !isUnsigned0 && isUnsigned: 102 if arg0 >= 0 && arg1 == arg0 { 103 compareResult = 0 104 } 105 case isUnsigned0 && !isUnsigned: 106 if arg1 >= 0 && arg1 == arg0 { 107 compareResult = 0 108 } 109 } 110 if compareResult == 0 { 111 result.SetNull(i, false) 112 r64s[i] = 1 113 } 114 } // for i 115 } // for j 116 for i := 0; i < n; i++ { 117 if result.IsNull(i) { 118 result.SetNull(i, hasNull[i]) 119 } 120 } 121 return nil 122 } 123 124 func (b *builtinInIntSig) vectorized() bool { 125 return true 126 } 127 128 func (b *builtinInStringSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 129 n := input.NumEvents() 130 buf0, err := b.bufSlabPredictor.get(types.ETString, n) 131 if err != nil { 132 return err 133 } 134 defer b.bufSlabPredictor.put(buf0) 135 if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil { 136 return err 137 } 138 buf1, err := b.bufSlabPredictor.get(types.ETString, n) 139 if err != nil { 140 return err 141 } 142 defer b.bufSlabPredictor.put(buf1) 143 144 result.ResizeInt64(n, true) 145 r64s := result.Int64s() 146 for i := 0; i < n; i++ { 147 r64s[i] = 0 148 } 149 hasNull := make([]bool, n) 150 if b.hasNull { 151 for i := 0; i < n; i++ { 152 hasNull[i] = true 153 } 154 } 155 var compareResult int 156 args := b.args 157 if len(b.hashSet) != 0 { 158 defCauslator := defCauslate.GetDefCauslator(b.defCauslation) 159 args = b.nonConstArgs 160 for i := 0; i < n; i++ { 161 if buf0.IsNull(i) { 162 hasNull[i] = true 163 continue 164 } 165 arg0 := buf0.GetString(i) 166 if _, ok := b.hashSet[string(defCauslator.Key(arg0))]; ok { 167 r64s[i] = 1 168 result.SetNull(i, false) 169 } 170 } 171 } 172 173 for j := 1; j < len(args); j++ { 174 if err := args[j].VecEvalString(b.ctx, input, buf1); err != nil { 175 return err 176 } 177 for i := 0; i < n; i++ { 178 if r64s[i] != 0 { 179 continue 180 } 181 if buf1.IsNull(i) || buf0.IsNull(i) { 182 hasNull[i] = true 183 continue 184 } 185 arg0 := buf0.GetString(i) 186 arg1 := buf1.GetString(i) 187 compareResult = types.CompareString(arg0, arg1, b.defCauslation) 188 if compareResult == 0 { 189 result.SetNull(i, false) 190 r64s[i] = 1 191 } 192 } // for i 193 } // for j 194 for i := 0; i < n; i++ { 195 if result.IsNull(i) { 196 result.SetNull(i, hasNull[i]) 197 } 198 } 199 return nil 200 } 201 202 func (b *builtinInStringSig) vectorized() bool { 203 return true 204 } 205 206 func (b *builtinInDecimalSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 207 n := input.NumEvents() 208 buf0, err := b.bufSlabPredictor.get(types.ETDecimal, n) 209 if err != nil { 210 return err 211 } 212 defer b.bufSlabPredictor.put(buf0) 213 if err := b.args[0].VecEvalDecimal(b.ctx, input, buf0); err != nil { 214 return err 215 } 216 buf1, err := b.bufSlabPredictor.get(types.ETDecimal, n) 217 if err != nil { 218 return err 219 } 220 defer b.bufSlabPredictor.put(buf1) 221 222 args0 := buf0.Decimals() 223 result.ResizeInt64(n, true) 224 r64s := result.Int64s() 225 for i := 0; i < n; i++ { 226 r64s[i] = 0 227 } 228 hasNull := make([]bool, n) 229 if b.hasNull { 230 for i := 0; i < n; i++ { 231 hasNull[i] = true 232 } 233 } 234 var compareResult int 235 args := b.args 236 if len(b.hashSet) != 0 { 237 args = b.nonConstArgs 238 for i := 0; i < n; i++ { 239 if buf0.IsNull(i) { 240 hasNull[i] = true 241 continue 242 } 243 arg0 := args0[i] 244 key, err := arg0.ToHashKey() 245 if err != nil { 246 return err 247 } 248 if _, ok := b.hashSet[string(key)]; ok { 249 r64s[i] = 1 250 result.SetNull(i, false) 251 } 252 } 253 } 254 255 for j := 1; j < len(args); j++ { 256 if err := args[j].VecEvalDecimal(b.ctx, input, buf1); err != nil { 257 return err 258 } 259 args1 := buf1.Decimals() 260 buf1.MergeNulls(buf0) 261 for i := 0; i < n; i++ { 262 if r64s[i] != 0 { 263 continue 264 } 265 if buf1.IsNull(i) { 266 hasNull[i] = true 267 continue 268 } 269 arg0 := args0[i] 270 arg1 := args1[i] 271 compareResult = 1 272 if arg0.Compare(&arg1) == 0 { 273 compareResult = 0 274 } 275 if compareResult == 0 { 276 result.SetNull(i, false) 277 r64s[i] = 1 278 } 279 } // for i 280 } // for j 281 for i := 0; i < n; i++ { 282 if result.IsNull(i) { 283 result.SetNull(i, hasNull[i]) 284 } 285 } 286 return nil 287 } 288 289 func (b *builtinInDecimalSig) vectorized() bool { 290 return true 291 } 292 293 func (b *builtinInRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 294 n := input.NumEvents() 295 buf0, err := b.bufSlabPredictor.get(types.ETReal, n) 296 if err != nil { 297 return err 298 } 299 defer b.bufSlabPredictor.put(buf0) 300 if err := b.args[0].VecEvalReal(b.ctx, input, buf0); err != nil { 301 return err 302 } 303 buf1, err := b.bufSlabPredictor.get(types.ETReal, n) 304 if err != nil { 305 return err 306 } 307 defer b.bufSlabPredictor.put(buf1) 308 309 args0 := buf0.Float64s() 310 result.ResizeInt64(n, true) 311 r64s := result.Int64s() 312 for i := 0; i < n; i++ { 313 r64s[i] = 0 314 } 315 hasNull := make([]bool, n) 316 if b.hasNull { 317 for i := 0; i < n; i++ { 318 hasNull[i] = true 319 } 320 } 321 var compareResult int 322 args := b.args 323 if len(b.hashSet) != 0 { 324 args = b.nonConstArgs 325 for i := 0; i < n; i++ { 326 if buf0.IsNull(i) { 327 hasNull[i] = true 328 continue 329 } 330 arg0 := args0[i] 331 if _, ok := b.hashSet[arg0]; ok { 332 r64s[i] = 1 333 result.SetNull(i, false) 334 } 335 } 336 } 337 338 for j := 1; j < len(args); j++ { 339 if err := args[j].VecEvalReal(b.ctx, input, buf1); err != nil { 340 return err 341 } 342 args1 := buf1.Float64s() 343 buf1.MergeNulls(buf0) 344 for i := 0; i < n; i++ { 345 if r64s[i] != 0 { 346 continue 347 } 348 if buf1.IsNull(i) { 349 hasNull[i] = true 350 continue 351 } 352 arg0 := args0[i] 353 arg1 := args1[i] 354 compareResult = types.CompareFloat64(arg0, arg1) 355 if compareResult == 0 { 356 result.SetNull(i, false) 357 r64s[i] = 1 358 } 359 } // for i 360 } // for j 361 for i := 0; i < n; i++ { 362 if result.IsNull(i) { 363 result.SetNull(i, hasNull[i]) 364 } 365 } 366 return nil 367 } 368 369 func (b *builtinInRealSig) vectorized() bool { 370 return true 371 } 372 373 func (b *builtinInTimeSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 374 n := input.NumEvents() 375 buf0, err := b.bufSlabPredictor.get(types.ETDatetime, n) 376 if err != nil { 377 return err 378 } 379 defer b.bufSlabPredictor.put(buf0) 380 if err := b.args[0].VecEvalTime(b.ctx, input, buf0); err != nil { 381 return err 382 } 383 buf1, err := b.bufSlabPredictor.get(types.ETDatetime, n) 384 if err != nil { 385 return err 386 } 387 defer b.bufSlabPredictor.put(buf1) 388 389 args0 := buf0.Times() 390 result.ResizeInt64(n, true) 391 r64s := result.Int64s() 392 for i := 0; i < n; i++ { 393 r64s[i] = 0 394 } 395 hasNull := make([]bool, n) 396 if b.hasNull { 397 for i := 0; i < n; i++ { 398 hasNull[i] = true 399 } 400 } 401 var compareResult int 402 args := b.args 403 if len(b.hashSet) != 0 { 404 args = b.nonConstArgs 405 for i := 0; i < n; i++ { 406 if buf0.IsNull(i) { 407 hasNull[i] = true 408 continue 409 } 410 arg0 := args0[i] 411 if _, ok := b.hashSet[arg0]; ok { 412 r64s[i] = 1 413 result.SetNull(i, false) 414 } 415 } 416 } 417 418 for j := 1; j < len(args); j++ { 419 if err := args[j].VecEvalTime(b.ctx, input, buf1); err != nil { 420 return err 421 } 422 args1 := buf1.Times() 423 buf1.MergeNulls(buf0) 424 for i := 0; i < n; i++ { 425 if r64s[i] != 0 { 426 continue 427 } 428 if buf1.IsNull(i) { 429 hasNull[i] = true 430 continue 431 } 432 arg0 := args0[i] 433 arg1 := args1[i] 434 compareResult = arg0.Compare(arg1) 435 if compareResult == 0 { 436 result.SetNull(i, false) 437 r64s[i] = 1 438 } 439 } // for i 440 } // for j 441 for i := 0; i < n; i++ { 442 if result.IsNull(i) { 443 result.SetNull(i, hasNull[i]) 444 } 445 } 446 return nil 447 } 448 449 func (b *builtinInTimeSig) vectorized() bool { 450 return true 451 } 452 453 func (b *builtinInDurationSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 454 n := input.NumEvents() 455 buf0, err := b.bufSlabPredictor.get(types.ETDuration, n) 456 if err != nil { 457 return err 458 } 459 defer b.bufSlabPredictor.put(buf0) 460 if err := b.args[0].VecEvalDuration(b.ctx, input, buf0); err != nil { 461 return err 462 } 463 buf1, err := b.bufSlabPredictor.get(types.ETDuration, n) 464 if err != nil { 465 return err 466 } 467 defer b.bufSlabPredictor.put(buf1) 468 469 args0 := buf0.GoDurations() 470 result.ResizeInt64(n, true) 471 r64s := result.Int64s() 472 for i := 0; i < n; i++ { 473 r64s[i] = 0 474 } 475 hasNull := make([]bool, n) 476 if b.hasNull { 477 for i := 0; i < n; i++ { 478 hasNull[i] = true 479 } 480 } 481 var compareResult int 482 args := b.args 483 if len(b.hashSet) != 0 { 484 args = b.nonConstArgs 485 for i := 0; i < n; i++ { 486 if buf0.IsNull(i) { 487 hasNull[i] = true 488 continue 489 } 490 arg0 := args0[i] 491 if _, ok := b.hashSet[arg0]; ok { 492 r64s[i] = 1 493 result.SetNull(i, false) 494 } 495 } 496 } 497 498 for j := 1; j < len(args); j++ { 499 if err := args[j].VecEvalDuration(b.ctx, input, buf1); err != nil { 500 return err 501 } 502 args1 := buf1.GoDurations() 503 buf1.MergeNulls(buf0) 504 for i := 0; i < n; i++ { 505 if r64s[i] != 0 { 506 continue 507 } 508 if buf1.IsNull(i) { 509 hasNull[i] = true 510 continue 511 } 512 arg0 := args0[i] 513 arg1 := args1[i] 514 compareResult = types.CompareDuration(arg0, arg1) 515 if compareResult == 0 { 516 result.SetNull(i, false) 517 r64s[i] = 1 518 } 519 } // for i 520 } // for j 521 for i := 0; i < n; i++ { 522 if result.IsNull(i) { 523 result.SetNull(i, hasNull[i]) 524 } 525 } 526 return nil 527 } 528 529 func (b *builtinInDurationSig) vectorized() bool { 530 return true 531 } 532 533 func (b *builtinInJSONSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 534 n := input.NumEvents() 535 buf0, err := b.bufSlabPredictor.get(types.ETJson, n) 536 if err != nil { 537 return err 538 } 539 defer b.bufSlabPredictor.put(buf0) 540 if err := b.args[0].VecEvalJSON(b.ctx, input, buf0); err != nil { 541 return err 542 } 543 buf1, err := b.bufSlabPredictor.get(types.ETJson, n) 544 if err != nil { 545 return err 546 } 547 defer b.bufSlabPredictor.put(buf1) 548 549 result.ResizeInt64(n, true) 550 r64s := result.Int64s() 551 for i := 0; i < n; i++ { 552 r64s[i] = 0 553 } 554 hasNull := make([]bool, n) 555 var compareResult int 556 args := b.args 557 558 for j := 1; j < len(args); j++ { 559 if err := args[j].VecEvalJSON(b.ctx, input, buf1); err != nil { 560 return err 561 } 562 for i := 0; i < n; i++ { 563 if r64s[i] != 0 { 564 continue 565 } 566 if buf1.IsNull(i) || buf0.IsNull(i) { 567 hasNull[i] = true 568 continue 569 } 570 arg0 := buf0.GetJSON(i) 571 arg1 := buf1.GetJSON(i) 572 compareResult = json.CompareBinary(arg0, arg1) 573 if compareResult == 0 { 574 result.SetNull(i, false) 575 r64s[i] = 1 576 } 577 } // for i 578 } // for j 579 for i := 0; i < n; i++ { 580 if result.IsNull(i) { 581 result.SetNull(i, hasNull[i]) 582 } 583 } 584 return nil 585 } 586 587 func (b *builtinInJSONSig) vectorized() bool { 588 return true 589 }