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

Function readSliceRefAndType

go/fory/slice.go:76–104  ·  view source on GitHub ↗

readSliceRefAndType handles reference and type reading for slice serializers. Returns (true, 0) if a reference was resolved (value already set). Returns (false, typeId) if data should be written and typeId was read (if readType=true).

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

Source from the content-addressed store, hash-verified

74// Returns (true, 0) if a reference was resolved (value already set).
75// Returns (false, typeId) if data should be written and typeId was read (if readType=true).
76func readSliceRefAndType(ctx *ReadContext, refMode RefMode, readType bool, value reflect.Value) (bool, uint32) {
77 buf := ctx.Buffer()
78 ctxErr := ctx.Err()
79 switch refMode {
80 case RefModeTracking:
81 refID, refErr := ctx.RefResolver().TryPreserveRefId(buf)
82 if refErr != nil {
83 ctx.SetError(FromError(refErr))
84 return true, 0
85 }
86 if refID < int32(NotNullValueFlag) {
87 obj := ctx.RefResolver().GetReadObject(refID)
88 if obj.IsValid() {
89 value.Set(obj)
90 }
91 return true, 0
92 }
93 case RefModeNullOnly:
94 flag := buf.ReadInt8(ctxErr)
95 if flag == NullFlag {
96 return true, 0
97 }
98 }
99 var typeId uint32
100 if readType {
101 typeId = uint32(buf.ReadUint8(ctxErr))
102 }
103 return false, typeId
104}
105
106// Helper function to check if a value is null/nil
107func isNull(v reflect.Value) bool {

Callers 15

ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85
ReadMethod · 0.85

Calls 12

FromErrorFunction · 0.85
TryPreserveRefIdMethod · 0.80
GetReadObjectMethod · 0.80
ReadUint8Method · 0.80
int32Function · 0.50
uint32Function · 0.50
BufferMethod · 0.45
ErrMethod · 0.45
RefResolverMethod · 0.45
SetErrorMethod · 0.45
SetMethod · 0.45
ReadInt8Method · 0.45

Tested by

no test coverage detected