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

Function SkipFieldValueWithTypeFlag

go/fory/skip.go:43–124  ·  view source on GitHub ↗

SkipFieldValueWithTypeFlag skips a field value with explicit control over type info reading. readTypeInfo should be true if type info was written for this field (struct fields in compatible mode). Uses context error state for deferred error checking.

(ctx *ReadContext, fieldDef FieldDef, readRefFlag bool, readTypeInfo bool)

Source from the content-addressed store, hash-verified

41// readTypeInfo should be true if type info was written for this field (struct fields in compatible mode).
42// Uses context error state for deferred error checking.
43func SkipFieldValueWithTypeFlag(ctx *ReadContext, fieldDef FieldDef, readRefFlag bool, readTypeInfo bool) {
44 err := ctx.Err()
45 if readTypeInfo {
46 // Type info was written for this field (struct fields in compatible mode)
47 // Read ref flag first if needed
48 if readRefFlag {
49 refFlag := ctx.buffer.ReadInt8(err)
50 if refFlag == NullFlag {
51 return
52 }
53 if refFlag == RefFlag {
54 // Reference to already-seen object, skip the reference index
55 _ = ctx.buffer.ReadVarUint32(err)
56 return
57 }
58 // RefValueFlag (0) or NotNullValueFlag (-1) means we need to read the actual object
59 }
60
61 // Read type info (typeID + meta_index)
62 wroteTypeID := uint32(ctx.buffer.ReadUint8(err))
63 internalID := TypeId(wroteTypeID)
64
65 // Check if it's an EXT type first - EXT types don't have meta info like structs
66 if internalID == EXT {
67 typeInfo := readKnownTypeInfoForSkip(ctx, wroteTypeID)
68 if ctx.HasError() {
69 return
70 }
71 if typeInfo != nil && typeInfo.Serializer != nil {
72 // Use the serializer to read and discard the value
73 var dummy any
74 dummyVal := reflect.ValueOf(&dummy).Elem()
75 typeInfo.Serializer.Read(ctx, RefModeNone, false, false, dummyVal)
76 return
77 }
78 // If no serializer is registered, we can't skip this type
79 ctx.SetError(DeserializationErrorf("cannot skip EXT type %d: no serializer registered", wroteTypeID))
80 return
81 }
82
83 // Check if it's a NAMED_EXT type - need to read type info to find serializer
84 if internalID == NAMED_EXT {
85 typeInfo := readKnownTypeInfoForSkip(ctx, wroteTypeID)
86 if ctx.HasError() {
87 return
88 }
89 if typeInfo != nil && typeInfo.Serializer != nil {
90 // Use the serializer to read and discard the value
91 var dummy any
92 dummyVal := reflect.ValueOf(&dummy).Elem()
93 typeInfo.Serializer.Read(ctx, RefModeNone, false, false, dummyVal)
94 return
95 }
96 ctx.SetError(DeserializationError("cannot skip NAMED_EXT type: no serializer found"))
97 return
98 }
99
100 // Check if it's a struct type - need to read type info and skip struct data

Callers 4

skipFieldMethod · 0.85
ReadDataMethod · 0.85
SkipFieldValueFunction · 0.85
skipStructFunction · 0.85

Calls 15

readKnownTypeInfoForSkipFunction · 0.85
DeserializationErrorfFunction · 0.85
DeserializationErrorFunction · 0.85
skipStructFunction · 0.85
IsNamespacedTypeFunction · 0.85
skipValueFunction · 0.85
ReadUint8Method · 0.80
ReadMethod · 0.65
uint32Function · 0.50
TypeIdEnum · 0.50
ErrMethod · 0.45
ReadInt8Method · 0.45

Tested by

no test coverage detected