(
    decoder,
    writer_schema,
    named_schemas,
    reader_schema=None,
    return_record_name=False,
)
return record
A record is encoded by encoding the values of its fields in the order
    that they are declared. In other words, a record is encoded as just the
    concatenation of the encodings of its fields.  Field values are encoded per
    their schema.

    Schema Resolution:
     * the ordering of fields may be different: fields are matched by name.
     * schemas for fields with the same name in both records are resolved
         recursively.
     * if the writer's record contains a field with a name not present in the
         reader's record, the writer's value for that field is ignored.
     * if the reader's record schema has a field that contains a default value,
         and writer's schema does not have a field with the same name, then the
         reader should use the default value from its field.
     * if the reader's record schema has a field with no default value, and
         writer's schema does not have a field with the same name, then the
         field's value is unset.
A record is encoded by encoding the values of its fields in the order
    that they are declared. In other words, a record is encoded as just the
    concatenation of the encodings of its fields.  Field values are encoded per
    their schema.
A record is encoded by encoding the values of its fields in the order that they are declared . In other words a record is encoded as just the concatenation of the encodings of its fields . Field values are encoded per their schema .
def read_record(
    decoder,
    writer_schema,
    named_schemas,
    reader_schema=None,
    return_record_name=False,
):
    """A record is encoded by encoding the values of its fields in the order
    that they are declared. In other words, a record is encoded as just the
    concatenation of the encodings of its fields.  Field values are encoded per
    their schema.

    Schema Resolution:
     * the ordering of fields may be different: fields are matched by name.
     * schemas for fields with the same name in both records are resolved
         recursively.
     * if the writer's record contains a field with a name not present in the
         reader's record, the writer's value for that field is ignored.
     * if the reader's record schema has a field that contains a default value,
         and writer's schema does not have a field with the same name, then the
         reader should use the default value from its field.
     * if the reader's record schema has a field with no default value, and
         writer's schema does not have a field with the same name, then the
         field's value is unset.
    """
    record = {}
    if reader_schema is None:
        for field in writer_schema["fields"]:
            record[field["name"]] = read_data(
                decoder, field["type"], named_schemas, None, return_record_name
            )
    else:
        readers_field_dict = {}
        aliases_field_dict = {}
        for f in reader_schema["fields"]:
            readers_field_dict[f["name"]] = f
            for alias in f.get("aliases", []):
                aliases_field_dict[alias] = f

        for field in writer_schema["fields"]:
            readers_field = readers_field_dict.get(
                field["name"],
                aliases_field_dict.get(field["name"]),
            )
            if readers_field:
                record[readers_field["name"]] = read_data(
                    decoder,
                    field["type"],
                    named_schemas,
                    readers_field["type"],
                    return_record_name,
                )
            else:
                skip_data(decoder, field["type"], named_schemas)

        # fill in default values
        if len(readers_field_dict) > len(record):
            writer_fields = [f["name"] for f in writer_schema["fields"]]
            for f_name, field in readers_field_dict.items():
                if f_name not in writer_fields and f_name not in record:
                    if "default" in field:
                        record[field["name"]] = field["default"]
                    else:
                        msg = f'No default value for {field["name"]}'
                        raise SchemaResolutionError(msg)

    return record
def read_record ( decoder , writer_schema , named_schemas , reader_schema = None , return_record_name = False , ) : record = { } if reader_schema is None : for field in writer_schema [ "fields" ] : record [ field [ "name" ] ] = read_data ( decoder , field [ "type" ] , named_schemas , None , return_record_name ) else : readers_field_dict = { } aliases_field_dict = { } for f in reader_schema [ "fields" ] : readers_field_dict [ f [ "name" ] ] = f for alias in f . get ( "aliases" , [ ] ) : aliases_field_dict [ alias ] = f for field in writer_schema [ "fields" ] : readers_field = readers_field_dict . get ( field [ "name" ] , aliases_field_dict . get ( field [ "name" ] ) , ) if readers_field : record [ readers_field [ "name" ] ] = read_data ( decoder , field [ "type" ] , named_schemas , readers_field [ "type" ] , return_record_name , ) else : skip_data ( decoder , field [ "type" ] , named_schemas ) # fill in default values if len ( readers_field_dict ) > len ( record ) : writer_fields = [ f [ "name" ] for f in writer_schema [ "fields" ] ] for f_name , field in readers_field_dict . items ( ) : if f_name not in writer_fields and f_name not in record : if "default" in field : record [ field [ "name" ] ] = field [ "default" ] else : msg = f'No default value for {field["name"]}' raise SchemaResolutionError ( msg ) return record