You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/07/21 15:01:00 UTC
[GitHub] [pulsar] gaoran10 commented on a change in pull request #11400: [Python Client] Fix handle complex schema
gaoran10 commented on a change in pull request #11400:
URL: https://github.com/apache/pulsar/pull/11400#discussion_r674055519
##########
File path: pulsar-client-cpp/python/pulsar/schema/schema_avro.py
##########
@@ -45,14 +46,23 @@ def _get_serialized_value(self, x):
def encode(self, obj):
self._validate_object_type(obj)
buffer = io.BytesIO()
- m = {k: self._get_serialized_value(v) for k, v in obj.__dict__.items()}
+ m = self.encode_dict(obj.__dict__)
fastavro.schemaless_writer(buffer, self._schema, m)
return buffer.getvalue()
+ def encode_dict(self, d: dict):
+ obj = {}
+ for k, v in d.items():
+ if isinstance(v, Record):
+ obj[k] = self.encode_dict(v.__dict__)
Review comment:
I fixed this. PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org