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

Method Call

runtime/vam/expr/function/bytes.go:16–48  ·  view source on GitHub ↗
(args ...vector.Any)

Source from the content-addressed store, hash-verified

14}
15
16func (b *Base64) Call(args ...vector.Any) vector.Any {
17 if vec, ok := expr.CheckForNullThenError(args); ok {
18 return vec
19 }
20 val := vector.Under(args[0])
21 switch val.Type().ID() {
22 case super.IDBytes:
23 out := vector.NewStringEmpty(0)
24 for i := uint32(0); i < val.Len(); i++ {
25 bytes := vector.BytesValue(val, i)
26 out.Append(base64.StdEncoding.EncodeToString(bytes))
27 }
28 return out
29 case super.IDString:
30 errvals := vector.NewStringEmpty(0)
31 tags := make([]uint32, val.Len())
32 out := vector.NewBytesEmpty(0)
33 for i := uint32(0); i < val.Len(); i++ {
34 s := vector.StringValue(val, i)
35 bytes, err := base64.StdEncoding.DecodeString(s)
36 if err != nil {
37 errvals.Append(s)
38 tags[i] = 1
39 continue
40 }
41 out.Append(bytes)
42 }
43 err := vector.NewWrappedError(b.sctx, "base64: string argument is not base64", errvals)
44 return vector.NewDynamic(tags, []vector.Any{out, err})
45 default:
46 return vector.NewWrappedError(b.sctx, "base64: argument must a bytes or string type", val)
47 }
48}
49
50type Hex struct {
51 sctx *super.Context

Callers

nothing calls this directly

Calls 12

CheckForNullThenErrorFunction · 0.92
UnderFunction · 0.92
NewStringEmptyFunction · 0.92
BytesValueFunction · 0.92
NewBytesEmptyFunction · 0.92
StringValueFunction · 0.92
NewWrappedErrorFunction · 0.92
NewDynamicFunction · 0.92
IDMethod · 0.65
TypeMethod · 0.65
LenMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected