You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Doug Cutting (JIRA)" <ji...@apache.org> on 2012/05/12 01:35:50 UTC

[jira] [Updated] (AVRO-1046) ReflectDatumReader doesn't work with SpecificRecords containing an array of values

     [ https://issues.apache.org/jira/browse/AVRO-1046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1046:
-------------------------------

    Attachment: AVRO-1046.patch

ReflectDatumReader is intended to permit reading specific and generic objects too, so this would be an incompatible change.  Your patch causes existing tests to fail.

Here's a patch that instead fixes ReflectDatumReader to be able to better determine what kind of array to create.

Does this work for you?  All tests pass for me, including the ones you provided with your patch.
                
> ReflectDatumReader doesn't work with SpecificRecords containing an array of values
> ----------------------------------------------------------------------------------
>
>                 Key: AVRO-1046
>                 URL: https://issues.apache.org/jira/browse/AVRO-1046
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.6.2
>            Reporter: Gabriel Reid
>            Priority: Minor
>             Fix For: 1.7.0
>
>         Attachments: AVRO-1046.patch, AVRO-1046.patch
>
>
> When a ReflectDatumReader is used to read implementations of SpecificRecord, it fails if the SpecificRecord includes an (avro) array. This appears to be due to the fact that the newArray method in ReflectDatumReader works differently (based on a reflection-based schema) than the newArray method in GenericDatumReader (which is the base class of the DatumReaders).
> The included patch simply removes the delegation to SpecificData for the creation of a schema in the case of a SpecificRecord. My assumption is that the delegation to SpecificData is for performance reasons.
> The rationale in removing the delegation to SpecificData is that a) it doesn't work completely correctly, as demonstrated, and b) if a user is using ReflectDatumReader (instead of SpecificDatumReader) to read SpecificRecords, there may be other underlying reasons that reflection is specifically chosen, and so this intention should not be undermined by the delegation to SpecificData.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira