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

Function skip_unknown

cpp/fory/serialization/skip.cc:553–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553void skip_unknown(ReadContext &ctx) {
554 // UNKNOWN type means the actual type info is written inline.
555 // We need to read the type info and then skip based on the actual type.
556 // This is used for polymorphic fields like List<Animal>.
557 const TypeInfo *type_info = ctx.read_any_type_info(ctx.error());
558 if (FORY_PREDICT_FALSE(ctx.has_error())) {
559 return;
560 }
561 if (!type_info) {
562 ctx.set_error(Error::type_error("TypeInfo not found for UNKNOWN skip"));
563 return;
564 }
565
566 // Check the actual type and skip accordingly
567 TypeId actual_tid = static_cast<TypeId>(type_info->type_id);
568
569 switch (actual_tid) {
570 case TypeId::STRUCT:
571 case TypeId::COMPATIBLE_STRUCT:
572 case TypeId::NAMED_STRUCT:
573 case TypeId::NAMED_COMPATIBLE_STRUCT: {
574 // For struct types, we already have the type_info with field_infos
575 if (!type_info->type_meta) {
576 ctx.set_error(
577 Error::type_error("TypeMeta not found for UNKNOWN struct skip"));
578 return;
579 }
580 const auto &field_infos = type_info->type_meta->get_field_infos();
581 for (const auto &fi : field_infos) {
582 // Use precomputed ref_mode from field metadata
583 skip_field_value(ctx, fi.field_type, fi.field_type.ref_mode);
584 if (FORY_PREDICT_FALSE(ctx.has_error())) {
585 return;
586 }
587 }
588 return;
589 }
590 default: {
591 // For non-struct types (primitives, arrays, maps, etc.),
592 // recursively call skip_field_value with the actual type
593 FieldType actual_field_type;
594 actual_field_type.set_type_id(type_info->type_id);
595 actual_field_type.nullable = false;
596 skip_field_value(ctx, actual_field_type, RefMode::None);
597 return;
598 }
599 }
600}
601
602void skip_union(ReadContext &ctx) {
603 // Read the variant index

Callers 1

skip_field_valueFunction · 0.85

Calls 7

get_field_infosMethod · 0.80
set_type_idMethod · 0.80
skip_field_valueFunction · 0.70
errorMethod · 0.65
read_any_type_infoMethod · 0.45
has_errorMethod · 0.45
set_errorMethod · 0.45

Tested by

no test coverage detected