Skip to content

Use schemaless reader to handle complex schema #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions confluent_kafka/avro/serializer/message_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

HAS_FAST = False
try:
from fastavro.reader import read_data
from fastavro import schemaless_reader

HAS_FAST = True
except:
Expand Down Expand Up @@ -170,15 +170,15 @@ def _get_decoder_func(self, schema_id, payload):
# try to use fast avro
try:
schema_dict = schema.to_json()
read_data(payload, schema_dict)
schemaless_reader(payload, schema_dict)

# If we reach this point, this means we have fastavro and it can
# do this deserialization. Rewind since this method just determines
# the reader function and we need to deserialize again along the
# normal path.
payload.seek(curr_pos)

self.id_to_decoder_func[schema_id] = lambda p: read_data(p, schema_dict)
self.id_to_decoder_func[schema_id] = lambda p: schemaless_reader(p, schema_dict)
return self.id_to_decoder_func[schema_id]
except:
pass
Expand Down