opwvhk commented on code in PR #1776:
URL: https://github.com/apache/avro/pull/1776#discussion_r927507262
##########
lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java:
##########
@@ -229,8 +230,17 @@ protected AvroTypeException
addAvroTypeMsg(AvroTypeException e, String s) {
* representations.
*/
protected void writeRecord(Schema schema, Object datum, Encoder out) throws
IOException {
- Object state = data.getRecordState(datum, schema);
- for (Field f : schema.getFields()) {
+ final Schema realSchema;
+ if (datum instanceof GenericRecord && schema.hasChild()) {
+ realSchema = ((GenericRecord) datum).getSchema();
+ } else {
+ realSchema = schema;
+ }
+ if (!Objects.equals(realSchema, schema)) {
+ out.writeExtends(realSchema.getIndex());
+ }
Review Comment:
This creates two possible binary representations of the same (parent)
schema: one for writing a parent schema, and a different one for child schemata.
How can the reader distinguish between the two?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]