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

Method Call

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

Source from the content-addressed store, hash-verified

113}
114
115func (p *Position) Call(args ...vector.Any) vector.Any {
116 if vec, ok := expr.CheckForNullThenError(args); ok {
117 return vec
118 }
119 args = underAll(args)
120 vec, subVec := args[0], args[1]
121 if vec.Type().ID() != super.IDString {
122 return vector.NewWrappedError(p.sctx, "position: string arguments required", vec)
123 }
124 if subVec.Type().ID() != super.IDString {
125 return vector.NewWrappedError(p.sctx, "position: string arguments required", subVec)
126 }
127 vals := make([]int64, vec.Len())
128 for i := range vec.Len() {
129 s := vector.StringValue(vec, i)
130 sub := vector.StringValue(subVec, i)
131 vals[i] = int64(strings.Index(s, sub) + 1)
132 }
133 return vector.NewInt(super.TypeInt64, vals)
134}
135
136type Replace struct {
137 sctx *super.Context

Callers

nothing calls this directly

Calls 9

CheckForNullThenErrorFunction · 0.92
NewWrappedErrorFunction · 0.92
StringValueFunction · 0.92
NewIntFunction · 0.92
IndexMethod · 0.80
underAllFunction · 0.70
IDMethod · 0.65
TypeMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected