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

Method encodePrimitive

sio/jsupio/writer.go:217–235  ·  view source on GitHub ↗
(sctx *super.Context, typ super.Type, v scode.Bytes)

Source from the content-addressed store, hash-verified

215}
216
217func (w *Writer) encodePrimitive(sctx *super.Context, typ super.Type, v scode.Bytes) (any, error) {
218 if typ == super.TypeType {
219 typ, err := sctx.LookupByValue(v)
220 if err != nil {
221 return nil, err
222 }
223 if super.TypeID(typ) < super.IDTypeComplex {
224 return super.PrimitiveName(typ), nil
225 }
226 if named, ok := typ.(*super.TypeNamed); ok {
227 return named.Name, nil
228 }
229 return strconv.Itoa(super.TypeID(typ)), nil
230 }
231 if typ.ID() == super.IDString {
232 return string(v), nil
233 }
234 return sup.FormatPrimitive(typ, v), nil
235}

Callers 1

encodeValueMethod · 0.95

Calls 5

TypeIDFunction · 0.92
PrimitiveNameFunction · 0.92
FormatPrimitiveFunction · 0.92
LookupByValueMethod · 0.80
IDMethod · 0.65

Tested by

no test coverage detected