[
https://issues.apache.org/jira/browse/AVRO-2248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16664205#comment-16664205
]
ASF GitHub Bot commented on AVRO-2248:
--------------------------------------
vamsi360 opened a new pull request #356: AVRO-2248 Custom parameterized types
URL: https://github.com/apache/avro/pull/356
This patch allows support for Java Parameterised types in Avro. Ex: Pair<K,
V>
Corresponding JIRA is: https://issues.apache.org/jira/browse/AVRO-2248
Please review this and I am willing to take suggestions and make required
changes to mainline this. Thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Added support for Java parameterised types with ReflectData in Avro
> -------------------------------------------------------------------
>
> Key: AVRO-2248
> URL: https://issues.apache.org/jira/browse/AVRO-2248
> Project: Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.8.2
> Reporter: Vamsi Subhash Achanta
> Priority: Major
>
> Hi all,
> Avro doesn't have support for Parameterised types currently. Ex:
> class Pair<K,V> {
> K key;
> V value;
> }
> For the above class, the schema generation fails when using ReflectData and
> ReflectDatumWriter. This is because the type information is not handled
> within the avro code and is not passed over.
> For Map/Collection, it is explictly hardcoded and supported within the code
> but for other generic types, it is not. The fix is modelled on how Map is
> solved internally and generalises it for all generic type parameters.
> The fix (and patch attached) addresses this by adding a new type called PARAM
> (like MAP) and is handled in all places including:
> * schema generation using ReflectData..getSchema(..
> * schema parsing using Schema.Parser
> * serialization to bytes using ReflectDatumWriter
> * de-serialization from bytes to object using ReflectDatumReader
> The test for the above cases is included in the patch and we have tested it
> with ~15 level nested type param schemas in our codebase internally here. The
> current code works for our cases. We are open to fixing bugs that might arise
> out of this if any.
> Please help us mainline this into avro code as it can be a very useful
> feature to all. Thanks a lot for the great project!
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)