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

Method skipField

go/fory/struct.go:2680–2707  ·  view source on GitHub ↗

skipField skips a field that doesn't exist or is incompatible Uses context error state for deferred error checking.

(ctx *ReadContext, field *FieldInfo)

Source from the content-addressed store, hash-verified

2678// skipField skips a field that doesn't exist or is incompatible
2679// Uses context error state for deferred error checking.
2680func (s *structSerializer) skipField(ctx *ReadContext, field *FieldInfo) {
2681 if field.Meta.FieldDef.name != "" || field.Meta.FieldDef.tagID >= 0 {
2682 if DebugOutputEnabled {
2683 fmt.Printf("[Go][fory-debug] skipField name=%s typeId=%d fieldType=%s\n",
2684 field.Meta.FieldDef.name,
2685 field.Meta.FieldDef.typeSpec.TypeId(),
2686 fieldTypeToString(field.Meta.FieldDef.typeSpec))
2687 }
2688 fieldDefIsStructType := isStructFieldType(field.Meta.FieldDef.typeSpec)
2689 // Use FieldDef's trackRef and nullable to determine if ref flag was written by Java
2690 // Java writes ref flag based on its FieldDef, not Go's field type
2691 readRefFlag := field.Meta.FieldDef.trackRef || field.Meta.FieldDef.nullable
2692 SkipFieldValueWithTypeFlag(ctx, field.Meta.FieldDef, readRefFlag, ctx.Compatible() && fieldDefIsStructType)
2693 return
2694 }
2695 // No FieldDef available, read into temp value
2696 tempValue := reflect.New(field.Meta.Type).Elem()
2697 if field.Serializer != nil {
2698 readType := ctx.Compatible() && isStructField(field.Meta.Type)
2699 refMode := RefModeNone
2700 if field.Meta.Nullable {
2701 refMode = RefModeTracking
2702 }
2703 field.Serializer.Read(ctx, refMode, readType, false, tempValue)
2704 } else {
2705 ctx.ReadValue(tempValue, RefModeTracking, true)
2706 }
2707}
2708
2709// writeEnumField writes an enum field respecting the field's RefMode.
2710// Java writes enum ordinals as unsigned VarUint32Small7, not signed zigzag.

Callers 1

readFieldsInOrderMethod · 0.95

Calls 8

fieldTypeToStringFunction · 0.85
isStructFieldTypeFunction · 0.85
isStructFieldFunction · 0.85
TypeIdMethod · 0.80
ReadValueMethod · 0.80
ReadMethod · 0.65
CompatibleMethod · 0.45

Tested by

no test coverage detected