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

Method Call

runtime/sam/expr/function/ksuid.go:12–35  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

10}
11
12func (k *KSUIDToString) Call(args []super.Value) super.Value {
13 if len(args) == 0 {
14 return super.NewBytes(ksuid.New().Bytes())
15 }
16 val := args[0]
17 switch val.Type().ID() {
18 case super.IDBytes:
19 id, err := ksuid.FromBytes(val.Bytes())
20 if err != nil {
21 return k.sctx.WrapError("ksuid: invalid ksuid value", val)
22 }
23 return super.NewString(id.String())
24 case super.IDString:
25 id, err := ksuid.Parse(string(val.Bytes()))
26 if err != nil {
27 return k.sctx.WrapError("ksuid: invalid ksuid value", val)
28 }
29 return super.NewBytes(id.Bytes())
30 case super.IDNull:
31 return super.Null
32 default:
33 return k.sctx.WrapError("ksuid: argument must a bytes or string type", val)
34 }
35}

Callers

nothing calls this directly

Calls 9

NewBytesFunction · 0.92
NewStringFunction · 0.92
NewMethod · 0.80
WrapErrorMethod · 0.80
ParseMethod · 0.80
IDMethod · 0.65
TypeMethod · 0.65
StringMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected