You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Rajiv S (JIRA)" <ji...@apache.org> on 2015/02/23 01:12:11 UTC

[jira] [Commented] (AVRO-1571) Support parameterized types in Avro

    [ https://issues.apache.org/jira/browse/AVRO-1571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14332440#comment-14332440 ] 

Rajiv S commented on AVRO-1571:
-------------------------------

What do you mean by 'ParentContext'? Is that the enclosing class? Can you please share the code you used to make it work?
 
We are generating the schema on the fly based on the incoming class instance. It is failing because we have a parameterized class within the class.

class Record  <T> {
    T value
}

org.apache.avro.AvroTypeException: Unknown type: T
	at org.apache.avro.specific.SpecificData.createSchema(SpecificData.java:255)
	at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:514)
	at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:189)

Doesn't look like there is a patch for this issue yet.

> Support parameterized types in Avro
> -----------------------------------
>
>                 Key: AVRO-1571
>                 URL: https://issues.apache.org/jira/browse/AVRO-1571
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>
> The below code cannot be serialized by Avro.
> {code}
> class ParameterTypes {
>   Master1 m1;
>   Master2 m2;
>   Master3<Integer> m3;
> }
> class Foo <P, Q> {
>   P p;
>   Q q;
> }
> class Master1 {
>   Foo <Integer, Long> foo;
> }
> class Master2 {
>   Foo <String, String> foo;
> }
> class Master3 <P> {
>   Foo <P, P> foo;
> }
> {code}
> This is because when generating the schema, only the current class is used to generate the schema. The parent class' context is missing in ReflectData#createSchema() functions where the actual type-information is present.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)