github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/builtin_string_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/milevadb/types" 20 "github.com/whtcorpsinc/milevadb/soliton/chunk" 21 ) 22 23 // vecEvalInt evals FIELD(str,str1,str2,str3,...). 24 // See https://dev.allegrosql.com/doc/refman/5.7/en/string-functions.html#function_field 25 func (b *builtinFieldIntSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 26 n := input.NumEvents() 27 buf0, err := b.bufSlabPredictor.get(types.ETInt, n) 28 if err != nil { 29 return err 30 } 31 defer b.bufSlabPredictor.put(buf0) 32 if err := b.args[0].VecEvalInt(b.ctx, input, buf0); err != nil { 33 return err 34 } 35 buf1, err := b.bufSlabPredictor.get(types.ETInt, n) 36 if err != nil { 37 return err 38 } 39 defer b.bufSlabPredictor.put(buf1) 40 41 arg0 := buf0.Int64s() 42 43 result.ResizeInt64(n, false) 44 i64s := result.Int64s() 45 for i := 0; i < n; i++ { 46 i64s[i] = 0 47 } 48 for i := 1; i < len(b.args); i++ { 49 if err := b.args[i].VecEvalInt(b.ctx, input, buf1); err != nil { 50 return err 51 } 52 53 arg1 := buf1.Int64s() 54 55 for j := 0; j < n; j++ { 56 if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) { 57 continue 58 } 59 60 if arg0[j] == arg1[j] { 61 62 i64s[j] = int64(i) 63 } 64 } 65 } 66 return nil 67 } 68 69 func (b *builtinFieldIntSig) vectorized() bool { 70 return true 71 } 72 73 // vecEvalInt evals FIELD(str,str1,str2,str3,...). 74 // See https://dev.allegrosql.com/doc/refman/5.7/en/string-functions.html#function_field 75 func (b *builtinFieldRealSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 76 n := input.NumEvents() 77 buf0, err := b.bufSlabPredictor.get(types.ETReal, n) 78 if err != nil { 79 return err 80 } 81 defer b.bufSlabPredictor.put(buf0) 82 if err := b.args[0].VecEvalReal(b.ctx, input, buf0); err != nil { 83 return err 84 } 85 buf1, err := b.bufSlabPredictor.get(types.ETReal, n) 86 if err != nil { 87 return err 88 } 89 defer b.bufSlabPredictor.put(buf1) 90 91 arg0 := buf0.Float64s() 92 93 result.ResizeInt64(n, false) 94 i64s := result.Int64s() 95 for i := 0; i < n; i++ { 96 i64s[i] = 0 97 } 98 for i := 1; i < len(b.args); i++ { 99 if err := b.args[i].VecEvalReal(b.ctx, input, buf1); err != nil { 100 return err 101 } 102 103 arg1 := buf1.Float64s() 104 105 for j := 0; j < n; j++ { 106 if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) { 107 continue 108 } 109 110 if arg0[j] == arg1[j] { 111 112 i64s[j] = int64(i) 113 } 114 } 115 } 116 return nil 117 } 118 119 func (b *builtinFieldRealSig) vectorized() bool { 120 return true 121 } 122 123 // vecEvalInt evals FIELD(str,str1,str2,str3,...). 124 // See https://dev.allegrosql.com/doc/refman/5.7/en/string-functions.html#function_field 125 func (b *builtinFieldStringSig) vecEvalInt(input *chunk.Chunk, result *chunk.DeferredCauset) error { 126 n := input.NumEvents() 127 buf0, err := b.bufSlabPredictor.get(types.ETString, n) 128 if err != nil { 129 return err 130 } 131 defer b.bufSlabPredictor.put(buf0) 132 if err := b.args[0].VecEvalString(b.ctx, input, buf0); err != nil { 133 return err 134 } 135 buf1, err := b.bufSlabPredictor.get(types.ETString, n) 136 if err != nil { 137 return err 138 } 139 defer b.bufSlabPredictor.put(buf1) 140 141 result.ResizeInt64(n, false) 142 i64s := result.Int64s() 143 for i := 0; i < n; i++ { 144 i64s[i] = 0 145 } 146 for i := 1; i < len(b.args); i++ { 147 if err := b.args[i].VecEvalString(b.ctx, input, buf1); err != nil { 148 return err 149 } 150 151 for j := 0; j < n; j++ { 152 if i64s[j] > 0 || buf0.IsNull(j) || buf1.IsNull(j) { 153 continue 154 } 155 156 if b.ctor.Compare(buf0.GetString(j), buf1.GetString(j)) == 0 { 157 158 i64s[j] = int64(i) 159 } 160 } 161 } 162 return nil 163 } 164 165 func (b *builtinFieldStringSig) vectorized() bool { 166 return true 167 }