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

Method Call

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

Source from the content-addressed store, hash-verified

138}
139
140func (r *Replace) Call(args ...vector.Any) vector.Any {
141 if vec, ok := expr.CheckForNullThenError(args); ok {
142 return vec
143 }
144 args = underAll(args)
145 for _, arg := range args {
146 if arg.Type() != super.TypeString {
147 return vector.NewWrappedError(r.sctx, "replace: string arg required", arg)
148 }
149 }
150 sVal := args[0]
151 out := vector.NewStringEmpty(0)
152 for i := range sVal.Len() {
153 s := vector.StringValue(sVal, i)
154 old := vector.StringValue(args[1], i)
155 new := vector.StringValue(args[2], i)
156 out.Append(strings.ReplaceAll(s, old, new))
157 }
158 return out
159}
160
161type Split struct {
162 sctx *super.Context

Callers

nothing calls this directly

Calls 8

CheckForNullThenErrorFunction · 0.92
NewWrappedErrorFunction · 0.92
NewStringEmptyFunction · 0.92
StringValueFunction · 0.92
underAllFunction · 0.70
TypeMethod · 0.65
LenMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected