(args ...vector.Any)
| 48 | } |
| 49 | |
| 50 | func (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 | |
| 87 | type Levenshtein struct { |
| 88 | sctx *super.Context |
nothing calls this directly
no test coverage detected