(
    decoder, writer_schema, named_schemas, reader_schema=None, return_record_name=False
)
Read data from file object according to schema.
Read data from file object according to schema.
Read data from file object according to schema .
def read_data(
    decoder, writer_schema, named_schemas, reader_schema=None, return_record_name=False
):
    """Read data from file object according to schema."""

    record_type = extract_record_type(writer_schema)

    if reader_schema and record_type in AVRO_TYPES:
        # If the schemas are the same, set the reader schema to None so that no
        # schema resolution is done for this call or future recursive calls
        if writer_schema == reader_schema:
            reader_schema = None
        else:
            reader_schema = match_schemas(writer_schema, reader_schema)

    reader_fn = READERS.get(record_type)
    if reader_fn:
        try:
            data = reader_fn(
                decoder,
                writer_schema,
                named_schemas,
                reader_schema,
                return_record_name,
            )
        except StructError:
            raise EOFError(f"cannot read {record_type} from {decoder.fo}")

        if "logicalType" in writer_schema:
            logical_type = extract_logical_type(writer_schema)
            fn = LOGICAL_READERS.get(logical_type)
            if fn:
                return fn(data, writer_schema, reader_schema)

        if reader_schema is not None:
            return maybe_promote(data, record_type, extract_record_type(reader_schema))
        else:
            return data
    else:
        return read_data(
            decoder,
            named_schemas[record_type],
            named_schemas,
            named_schemas.get(reader_schema),
            return_record_name,
        )
def read_data ( decoder , writer_schema , named_schemas , reader_schema = None , return_record_name = False ) : record_type = extract_record_type ( writer_schema ) if reader_schema and record_type in AVRO_TYPES : # If the schemas are the same, set the reader schema to None so that no # schema resolution is done for this call or future recursive calls if writer_schema == reader_schema : reader_schema = None else : reader_schema = match_schemas ( writer_schema , reader_schema ) reader_fn = READERS . get ( record_type ) if reader_fn : try : data = reader_fn ( decoder , writer_schema , named_schemas , reader_schema , return_record_name , ) except StructError : raise EOFError ( f"cannot read {record_type} from {decoder.fo}" ) if "logicalType" in writer_schema : logical_type = extract_logical_type ( writer_schema ) fn = LOGICAL_READERS . get ( logical_type ) if fn : return fn ( data , writer_schema , reader_schema ) if reader_schema is not None : return maybe_promote ( data , record_type , extract_record_type ( reader_schema ) ) else : return data else : return read_data ( decoder , named_schemas [ record_type ] , named_schemas , named_schemas . get ( reader_schema ) , return_record_name , )