AvroSerializer Class
AvroSerializer provides the ability to serialize and deserialize data according to the given avro schema. It would automatically register, get and cache the schema.
- Inheritance
-
builtins.objectAvroSerializer
Constructor
AvroSerializer(**kwargs: Any)
Parameters
- client
- SchemaRegistryClient
Required. The schema registry client which is used to register schema and retrieve schema from the service.
- group_name
- str
Required. Schema group under which schema should be registered.
- auto_register_schemas
- bool
When true, register new schemas passed to serialize. Otherwise, and by default, serialization will fail if the schema has not been pre-registered in the registry.
Methods
| close |
This method is to close the sockets opened by the client. It need not be used when using with a context manager. |
| deserialize |
Decode bytes data. Data must follow format of associated Avro RecordSchema: https://avro.apache.org/docs/1.10.0/gettingstartedpython.html#Defining+a+schema |
| serialize |
Encode data with the given schema. The returns bytes are consisted of: The first 4 bytes denoting record format identifier. The following 32 bytes denoting schema id returned by schema registry service. The remaining bytes are the real data payload. Schema must be an Avro RecordSchema: https://avro.apache.org/docs/1.10.0/gettingstartedpython.html#Defining+a+schema |
close
This method is to close the sockets opened by the client. It need not be used when using with a context manager.
close() -> None
deserialize
Decode bytes data.
Data must follow format of associated Avro RecordSchema: https://avro.apache.org/docs/1.10.0/gettingstartedpython.html#Defining+a+schema
deserialize(value: bytes, **kwargs: Any) -> Dict[str, Any]
Parameters
Return type
Exceptions
Indicates an issue with parsing schema.
Indicates an issue with deserializing value.
serialize
Encode data with the given schema. The returns bytes are consisted of: The first 4 bytes denoting record format identifier. The following 32 bytes denoting schema id returned by schema registry service. The remaining bytes are the real data payload.
Schema must be an Avro RecordSchema: https://avro.apache.org/docs/1.10.0/gettingstartedpython.html#Defining+a+schema
serialize(value: Mapping[str, Any], **kwargs: Any) -> bytes
Parameters
- schema
- str
Required. The schema used to encode the data.
Return type
Exceptions
Indicates an issue with parsing schema.
Indicates an issue with serializing data for provided schema.
Feedback
Submit and view feedback for