avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sachin Goyal (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1568) Allow Java polymorphism in Avro for third-party code
Date Sun, 24 Aug 2014 07:07:11 GMT

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

Sachin Goyal commented on AVRO-1568:
------------------------------------

Yes, that would be more generic.
We can also provide another flavor of the API as #setSchema (java.lang.reflect.Field, Schema)
This can come in handy when its known that only one particular field will hold polymorphic
types and thus other Fields of same type need not pay the penalty of the bigger polymorphic
schema.

> Allow Java polymorphism in Avro for third-party code
> ----------------------------------------------------
>
>                 Key: AVRO-1568
>                 URL: https://issues.apache.org/jira/browse/AVRO-1568
>             Project: Avro
>          Issue Type: Improvement
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>
> A large number of Java designs interacting with databases with Hibernate/Couchbase (perhaps,
even otherwise) have Java polymorphism of the form:
> {code:java}
> class Base 
> {
>    Integer a = 5;
> }
> class Derived extends Base
> {
>     String b = "Foo";
> }
> class PolymorphicDO
> {
>    Base b = new Derived();
> }
> {code}
> Jackson handles this kind of field by using annotations such as:
> {code}
> @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property
= "@class”)
> {code}
> If such a thing can be added to Avro, all those Java designs could become immediately
usable with Avro. They would also become Hadoop compatible due to AvroSerde.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message