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

Ryan Blue commented on AVRO-1568:
---------------------------------

bq. Do we expect avro-serializiable classes to have these APIs?

Yes and no. I would expect the API to have enough information to be able to 
reconstruct the object, but I don't think it would necessarily have such a nice 
API to provide a serialized version of itself. I think the more common case 
would be like the following, where you have a factory method (or constructor) 
and accessors for the data:

{code:java}
interface Point:
  cartesianPoint(float x, float y)
  polarPoint(float r, float theta)
  float getX()
  float getY()
{code}

Here we don't know anything about the internals of the concrete Point 
implementation, but can construct perfectly reasonable points.

> 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.3.4#6332)

Reply via email to