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

Function skipCollection

go/fory/skip.go:236–305  ·  view source on GitHub ↗

skipCollection skips a collection (list/set) value Uses context error state for deferred error checking.

(ctx *ReadContext, fieldDef FieldDef)

Source from the content-addressed store, hash-verified

234// skipCollection skips a collection (list/set) value
235// Uses context error state for deferred error checking.
236func skipCollection(ctx *ReadContext, fieldDef FieldDef) {
237 err := ctx.Err()
238 length := uint32(ctx.ReadCollectionLength())
239 if ctx.HasError() || length == 0 {
240 return
241 }
242
243 header := ctx.buffer.ReadByte(err)
244 if ctx.HasError() {
245 return
246 }
247
248 hasNull := (header & CollectionHasNull) != 0
249 isSameType := (header & CollectionIsSameType) != 0
250 trackRef := (header & CollectionTrackingRef) != 0
251 isDeclared := (header & CollectionIsDeclElementType) != 0
252
253 var elemDef FieldDef
254 var elemTypeInfo *TypeInfo
255 if isSameType && !isDeclared {
256 // ReadData element type info - first read the typeID from buffer
257 typeID := uint32(ctx.buffer.ReadUint8(err))
258 if ctx.HasError() {
259 return
260 }
261 elemTypeInfo = readKnownTypeInfoForSkip(ctx, typeID)
262 if ctx.HasError() {
263 return
264 }
265 elemDef = FieldDef{
266 typeSpec: NewSimpleTypeSpec(TypeId(elemTypeInfo.TypeID)),
267 nullable: hasNull,
268 }
269 } else if isDeclared {
270 // Use declared element type from the collection's field type
271 if fieldDef.typeSpec != nil && fieldDef.typeSpec.elementType != nil {
272 elemDef = FieldDef{
273 typeSpec: fieldDef.typeSpec.elementType,
274 nullable: hasNull,
275 }
276 } else {
277 // Fallback: use unknown type
278 elemDef = FieldDef{
279 typeSpec: NewSimpleTypeSpec(UNKNOWN),
280 nullable: true,
281 }
282 }
283 } else {
284 // Not same type - each element has its own type info, use unknown
285 elemDef = FieldDef{
286 typeSpec: NewSimpleTypeSpec(UNKNOWN),
287 nullable: true,
288 }
289 }
290
291 ctx.depth++
292 if ctx.depth > ctx.maxDepth {
293 ctx.SetError(MaxDepthExceededError(ctx.depth))

Callers 1

skipValueFunction · 0.85

Calls 13

readKnownTypeInfoForSkipFunction · 0.85
NewSimpleTypeSpecFunction · 0.85
MaxDepthExceededErrorFunction · 0.85
skipValueFunction · 0.85
ReadCollectionLengthMethod · 0.80
ReadUint8Method · 0.80
decDepthMethod · 0.80
uint32Function · 0.50
TypeIdEnum · 0.50
ErrMethod · 0.45
HasErrorMethod · 0.45
ReadByteMethod · 0.45

Tested by

no test coverage detected