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

Method Call

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

Source from the content-addressed store, hash-verified

52}
53
54func (h *Hex) Call(args ...vector.Any) vector.Any {
55 if vec, ok := expr.CheckForNullThenError(args); ok {
56 return vec
57 }
58 val := vector.Under(args[0])
59 switch val.Type().ID() {
60 case super.IDBytes:
61 out := vector.NewStringEmpty(val.Len())
62 for i := uint32(0); i < val.Len(); i++ {
63 bytes := vector.BytesValue(val, i)
64 out.Append(hex.EncodeToString(bytes))
65 }
66 return out
67 case super.IDString:
68 errvals := vector.NewStringEmpty(0)
69 tags := make([]uint32, val.Len())
70 out := vector.NewBytesEmpty(0)
71 for i := uint32(0); i < val.Len(); i++ {
72 s := vector.StringValue(val, i)
73 bytes, err := hex.DecodeString(s)
74 if err != nil {
75 errvals.Append(s)
76 tags[i] = 1
77 continue
78 }
79 out.Append(bytes)
80 }
81 err := vector.NewWrappedError(h.sctx, "hex: string argument is not hexidecimal", errvals)
82 return vector.NewDynamic(tags, []vector.Any{out, err})
83 default:
84 return vector.NewWrappedError(h.sctx, "hex: argument must a bytes or string type", val)
85 }
86}

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