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

Method ReadRefOrNull

go/fory/ref_resolver.go:198–212  ·  view source on GitHub ↗

ReadRefOrNull returns RefFlag if a ref to a previously read object was read. Returns NullFlag if the object is null. Returns RefValueFlag if the object is not null and ref tracking is not enabled or the object is first read.

(buffer *ByteBuffer, ctxErr *Error)

Source from the content-addressed store, hash-verified

196// was read. Returns NullFlag if the object is null. Returns RefValueFlag if the object is not
197// null and ref tracking is not enabled or the object is first read.
198func (r *RefResolver) ReadRefOrNull(buffer *ByteBuffer, ctxErr *Error) int8 {
199 refTag := buffer.ReadInt8(ctxErr)
200 if !r.refTracking {
201 return refTag
202 }
203 if refTag == RefFlag {
204 // read ref id and get object from ref resolver
205 refId := buffer.ReadVarUint32(ctxErr)
206 r.readObject = r.GetReadObject(int32(refId))
207 return RefFlag
208 } else {
209 r.readObject = reflect.Value{}
210 }
211 return refTag
212}
213
214// PreserveRefId preserve a ref id, which is used by Reference / SetReadObject to
215// set up reference for object that is first deserialized.

Callers 3

TestReferenceResolverFunction · 0.80
TestNonReferenceResolverFunction · 0.80
TestRefResolverOOBPanicFunction · 0.80

Calls 4

GetReadObjectMethod · 0.95
int32Function · 0.50
ReadInt8Method · 0.45
ReadVarUint32Method · 0.45

Tested by 3

TestReferenceResolverFunction · 0.64
TestNonReferenceResolverFunction · 0.64
TestRefResolverOOBPanicFunction · 0.64