SkipAnyValue skips any value by reading its type info first, then skipping the data. This is used for polymorphic types where the actual type is unknown at compile time. Uses context error state for deferred error checking.
(ctx *ReadContext, readRefFlag bool)
| 133 | // This is used for polymorphic types where the actual type is unknown at compile time. |
| 134 | // Uses context error state for deferred error checking. |
| 135 | func SkipAnyValue(ctx *ReadContext, readRefFlag bool) { |
| 136 | err := ctx.Err() |
| 137 | // Handle ref flag first if needed |
| 138 | if readRefFlag { |
| 139 | refFlag := ctx.buffer.ReadInt8(err) |
| 140 | if ctx.HasError() { |
| 141 | return |
| 142 | } |
| 143 | if refFlag == NullFlag { |
| 144 | return |
| 145 | } |
| 146 | if refFlag == RefFlag { |
| 147 | // Reference to already-seen object, skip the reference index |
| 148 | _ = ctx.buffer.ReadVarUint32(err) |
| 149 | return |
| 150 | } |
| 151 | // RefValueFlag (0) or NotNullValueFlag (-1) means we need to read the actual object |
| 152 | } |
| 153 | |
| 154 | // ReadData type_id first |
| 155 | typeID := uint32(ctx.buffer.ReadUint8(err)) |
| 156 | if ctx.HasError() { |
| 157 | return |
| 158 | } |
| 159 | internalID := TypeId(typeID) |
| 160 | |
| 161 | // For struct-like types, also read meta_index to get type_info |
| 162 | var fieldDef FieldDef |
| 163 | var typeInfo *TypeInfo |
| 164 | |
| 165 | switch internalID { |
| 166 | case LIST, SET: |
| 167 | fieldDef = FieldDef{ |
| 168 | typeSpec: NewCollectionTypeSpec(TypeId(typeID), NewSimpleTypeSpec(UNKNOWN)), |
| 169 | nullable: true, |
| 170 | } |
| 171 | case MAP: |
| 172 | fieldDef = FieldDef{ |
| 173 | typeSpec: NewMapTypeSpec(TypeId(typeID), NewSimpleTypeSpec(UNKNOWN), NewSimpleTypeSpec(UNKNOWN)), |
| 174 | nullable: true, |
| 175 | } |
| 176 | case ENUM, NAMED_ENUM, COMPATIBLE_STRUCT, NAMED_COMPATIBLE_STRUCT, STRUCT, NAMED_STRUCT, |
| 177 | EXT, NAMED_EXT, TYPED_UNION, NAMED_UNION: |
| 178 | // Read type info using the shared meta reader when enabled. |
| 179 | typeInfo = ctx.TypeResolver().readTypeInfoWithTypeID(ctx.buffer, typeID, err) |
| 180 | if ctx.HasError() { |
| 181 | return |
| 182 | } |
| 183 | if typeInfo == nil { |
| 184 | ctx.SetError(DeserializationErrorf("cannot skip type %d: type info not found", typeID)) |
| 185 | return |
| 186 | } |
| 187 | fieldDef = FieldDef{ |
| 188 | typeSpec: NewSimpleTypeSpec(TypeId(typeID)), |
| 189 | nullable: true, |
| 190 | } |
| 191 | default: |
| 192 | fieldDef = FieldDef{ |