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

Function NewEncoder

csup/encoder.go:37–65  ·  view source on GitHub ↗
(cctx *Context, typ super.Type)

Source from the content-addressed store, hash-verified

35}
36
37func NewEncoder(cctx *Context, typ super.Type) Encoder {
38 switch typ := typ.(type) {
39 case *super.TypeNamed:
40 return &NamedEncoder{NewEncoder(cctx, typ.Type), typ.Name}
41 case *super.TypeError:
42 return &ErrorEncoder{NewEncoder(cctx, typ.Type)}
43 case *super.TypeRecord:
44 return NewRecordEncoder(cctx, typ)
45 case *super.TypeArray:
46 return NewArrayEncoder(cctx, typ)
47 case *super.TypeSet:
48 // Sets encode the same way as arrays but behave
49 // differently semantically, and we don't care here.
50 return NewSetEncoder(cctx, typ)
51 case *super.TypeMap:
52 return NewMapEncoder(cctx, typ)
53 case *super.TypeUnion:
54 return NewUnionEncoder(cctx, typ)
55 case *super.TypeFusion:
56 return NewFusionEncoder(cctx, typ)
57 case *super.TypeEnum:
58 return NewPrimitiveEncoder(typ)
59 default:
60 if !super.IsPrimitiveType(typ) {
61 panic(fmt.Sprintf("unsupported type in CSUP file: %T", typ))
62 }
63 return NewDictEncoder(typ, NewPrimitiveEncoder(typ))
64 }
65}
66
67func NewPrimitiveEncoder(typ super.Type) PrimitiveEncoder {
68 switch id := typ.ID(); {

Callers 7

NewFusionEncoderFunction · 0.70
NewRecordEncoderFunction · 0.70
NewUnionEncoderFunction · 0.70
NewArrayEncoderFunction · 0.70
NewSetEncoderFunction · 0.70
NewMapEncoderFunction · 0.70
lookupTypeMethod · 0.70

Calls 9

IsPrimitiveTypeFunction · 0.92
NewRecordEncoderFunction · 0.85
NewArrayEncoderFunction · 0.85
NewSetEncoderFunction · 0.85
NewMapEncoderFunction · 0.85
NewUnionEncoderFunction · 0.85
NewFusionEncoderFunction · 0.85
NewPrimitiveEncoderFunction · 0.85
NewDictEncoderFunction · 0.85

Tested by

no test coverage detected