MCPcopy Create free account
hub / github.com/brimdata/super / Call

Method Call

runtime/sam/expr/function/string.go:166–195  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

164}
165
166func (j *Join) Call(args []super.Value) super.Value {
167 args = underAll(args)
168 for _, val := range args {
169 if val.IsNull() {
170 return super.Null
171 }
172 }
173 splitsVal := args[0]
174 typ, ok := super.TypeUnder(splitsVal.Type()).(*super.TypeArray)
175 if !ok || typ.Type.ID() != super.IDString {
176 return j.sctx.WrapError("join: array of string arg required", splitsVal)
177 }
178 var separator string
179 if len(args) == 2 {
180 sepVal := args[1]
181 if !sepVal.IsString() {
182 return j.sctx.WrapError("join: separator must be string", sepVal)
183 }
184 separator = super.DecodeString(sepVal.Bytes())
185 }
186 var b strings.Builder
187 var sep string
188 it := splitsVal.Bytes().Iter()
189 for !it.Done() {
190 b.WriteString(sep)
191 b.WriteString(super.DecodeString(it.Next()))
192 sep = separator
193 }
194 return super.NewString(b.String())
195}
196
197type Levenshtein struct {
198 sctx *super.Context

Callers

nothing calls this directly

Calls 14

TypeUnderFunction · 0.92
DecodeStringFunction · 0.92
NewStringFunction · 0.92
IsNullMethod · 0.80
WrapErrorMethod · 0.80
IsStringMethod · 0.80
IterMethod · 0.80
underAllFunction · 0.70
TypeMethod · 0.65
IDMethod · 0.65
StringMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected