clesaec commented on code in PR #1776:
URL: https://github.com/apache/avro/pull/1776#discussion_r927571179
##########
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:
Don't get this comment :
- schema variable represent the schema declaration (For a field or an array
of)
- realSchema variable represent the effective schema of the record (datum).
if it's the same, no pb, we stay in classic situation, but if it's not the
same, we mark it as extended type.
--
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]