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

Method Call

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

Source from the content-addressed store, hash-verified

163}
164
165func (s *Split) Call(args ...vector.Any) vector.Any {
166 if vec, ok := expr.CheckForNullThenError(args); ok {
167 return vec
168 }
169 args = underAll(args)
170 for i := range args {
171 if args[i].Type() != super.TypeString {
172 return vector.NewWrappedError(s.sctx, "split: string arg required", args[i])
173 }
174 }
175 sVal, sepVal := args[0], args[1]
176 var offsets []uint32
177 values := vector.NewStringEmpty(0)
178 var off uint32
179 for i := uint32(0); i < sVal.Len(); i++ {
180 ss := vector.StringValue(sVal, i)
181 sep := vector.StringValue(sepVal, i)
182 splits := strings.Split(ss, sep)
183 for _, substr := range splits {
184 values.Append(substr)
185 }
186 offsets = append(offsets, off)
187 off += uint32(len(splits))
188 }
189 offsets = append(offsets, off)
190 return vector.NewArray(s.sctx.LookupTypeArray(super.TypeString), offsets, values)
191}
192
193type ToLower struct {
194 sctx *super.Context

Callers

nothing calls this directly

Calls 11

CheckForNullThenErrorFunction · 0.92
NewWrappedErrorFunction · 0.92
NewStringEmptyFunction · 0.92
StringValueFunction · 0.92
NewArrayFunction · 0.92
SplitMethod · 0.80
LookupTypeArrayMethod · 0.80
underAllFunction · 0.70
TypeMethod · 0.65
LenMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected