MCPcopy Create free account
hub / github.com/apache/fory / Read

Method Read

go/fory/union.go:199–226  ·  view source on GitHub ↗

Read is the entry point for union deserialization.

(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value)

Source from the content-addressed store, hash-verified

197
198// Read is the entry point for union deserialization.
199func (s *UnionSerializer) Read(ctx *ReadContext, refMode RefMode, readType bool, hasGenerics bool, value reflect.Value) {
200 _ = hasGenerics
201 err := ctx.Err()
202 switch refMode {
203 case RefModeTracking:
204 refID, refErr := ctx.RefResolver().TryPreserveRefId(ctx.Buffer())
205 if refErr != nil {
206 ctx.SetError(FromError(refErr))
207 return
208 }
209 if refID < int32(NotNullValueFlag) {
210 obj := ctx.RefResolver().GetReadObject(refID)
211 if obj.IsValid() {
212 value.Set(obj)
213 }
214 return
215 }
216 case RefModeNullOnly:
217 flag := ctx.Buffer().ReadInt8(err)
218 if flag == NullFlag {
219 return
220 }
221 }
222 if readType {
223 ctx.TypeResolver().ReadTypeInfo(ctx.Buffer(), err)
224 }
225 s.ReadData(ctx, value)
226}
227
228// ReadData deserializes union payload (case_id + case_value).
229func (s *UnionSerializer) ReadData(ctx *ReadContext, value reflect.Value) {

Callers 1

ReadWithTypeInfoMethod · 0.95

Calls 13

ReadDataMethod · 0.95
FromErrorFunction · 0.85
TryPreserveRefIdMethod · 0.80
GetReadObjectMethod · 0.80
int32Function · 0.50
ErrMethod · 0.45
RefResolverMethod · 0.45
BufferMethod · 0.45
SetErrorMethod · 0.45
SetMethod · 0.45
ReadInt8Method · 0.45
ReadTypeInfoMethod · 0.45

Tested by

no test coverage detected