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

Method Call

runtime/vam/expr/function/string.go:50–85  ·  view source on GitHub ↗
(args ...vector.Any)

Source from the content-addressed store, hash-verified

48}
49
50func (j *Join) Call(args ...vector.Any) vector.Any {
51 if vec, ok := expr.CheckForNullThenError(args); ok {
52 return vec
53 }
54 args = underAll(args)
55 splitsVal := args[0]
56 typ, ok := splitsVal.Type().(*super.TypeArray)
57 if !ok || typ.Type.ID() != super.IDString {
58 return vector.NewWrappedError(j.sctx, "join: array of string arg required", splitsVal)
59 }
60 var sepVal vector.Any
61 if len(args) == 2 {
62 if sepVal = args[1]; sepVal.Type() != super.TypeString {
63 return vector.NewWrappedError(j.sctx, "join: separator must be string", sepVal)
64 }
65 }
66 out := vector.NewStringEmpty(0)
67 inner := vector.Inner(splitsVal)
68 for i := uint32(0); i < splitsVal.Len(); i++ {
69 var seperator string
70 if sepVal != nil {
71 seperator = vector.StringValue(sepVal, i)
72 }
73 off, end := vector.ContainerOffset(splitsVal, i)
74 var b strings.Builder
75 var sep string
76 for ; off < end; off++ {
77 s := vector.StringValue(inner, off)
78 b.WriteString(sep)
79 b.WriteString(s)
80 sep = seperator
81 }
82 out.Append(b.String())
83 }
84 return out
85}
86
87type Levenshtein struct {
88 sctx *super.Context

Callers

nothing calls this directly

Calls 12

TypeMethod · 0.95
CheckForNullThenErrorFunction · 0.92
NewWrappedErrorFunction · 0.92
NewStringEmptyFunction · 0.92
InnerFunction · 0.92
StringValueFunction · 0.92
ContainerOffsetFunction · 0.92
underAllFunction · 0.70
IDMethod · 0.65
LenMethod · 0.65
StringMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected