avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qiangqiang Shi (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-1759) Avro Schema Generator to handle polymorphic types
Date Mon, 16 Nov 2015 15:51:11 GMT

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

Qiangqiang Shi updated AVRO-1759:
---------------------------------
    Description: 
Inheritance and polymorphism are widely used in Java projects and libraries. It'll make people's
life easier if Avro could detect classes' hierarchy and generate Avro schema according to
the hierarchy. 

for example, for the following class:

{code:java}
public class TestReflectPolymorphismData {
{
public static class SuperclassA1 {
    private String SuperclassA1;
  }

  public static class SubclassA1 extends SuperclassA1 {
    private String SubclassA1;
  }

  public static class SubclassA2 extends SuperclassA1 {
    private String SubclassA2;
  }

public static class SuperB1 {
    private SubclassA1 SubclassA1;
    private List<SubclassA2> SubclassA2List;
    private Map<String, SuperclassA1> stringSuperclassA1Map;
    private Map<Integer, SuperclassA1> integerSuperclassA1Map;
  }
}
}
{code}

Avro should be able to generate a schema like the following one automatically :

{"type":"record","name":"SuperB1","namespace":"org.apache.avro.reflect.TestReflectPolymorphismData$","fields":[{"name":"SubclassA1","type":{"type":"record","name":"SuperclassA1","fields":[{"name":"SuperclassA1","type":"string"},{"name":"SuperclassA1Subclasses","type":["null",{"type":"record","name":"SubclassA1","fields":[{"name":"SubclassA1","type":"string"}]},{"type":"record","name":"SubclassA2","fields":[{"name":"SubclassA2","type":"string"}]}]}]}},{"name":"SubclassA2List","type":{"type":"array","items":"SuperclassA1","java-class":"java.util.List"}},{"name":"stringSuperclassA1Map","type":{"type":"map","values":"SuperclassA1"}},{"name":"integerSuperclassA1Map","type":{"type":"array","items":{"type":"record","name":"Pair34255fab6d3d79ff","namespace":"org.apache.avro.reflect","fields":[{"name":"key","type":"int"},{"name":"value","type":"org.apache.avro.reflect.TestReflectPolymorphismData$.SuperclassA1"}]},"java-class":"java.util.Map"}}]}

  was:
Inheritance and polymorphism are widely used in Java projects and libraries. It'll make people's
life easier if Avro could detect classes' hierarchy and generate Avro schema according to
the hierarchy. 

for example, for the following class:
{
public class TestReflectPolymorphismData {
{
public static class SuperclassA1 {
    private String SuperclassA1;
  }

  public static class SubclassA1 extends SuperclassA1 {
    private String SubclassA1;
  }

  public static class SubclassA2 extends SuperclassA1 {
    private String SubclassA2;
  }

public static class SuperB1 {
    private SubclassA1 SubclassA1;
    private List<SubclassA2> SubclassA2List;
    private Map<String, SuperclassA1> stringSuperclassA1Map;
    private Map<Integer, SuperclassA1> integerSuperclassA1Map;
  }
}
}
/}
Avro should be able to generate a schema like the following one automatically :

{"type":"record","name":"SuperB1","namespace":"org.apache.avro.reflect.TestReflectPolymorphismData$","fields":[{"name":"SubclassA1","type":{"type":"record","name":"SuperclassA1","fields":[{"name":"SuperclassA1","type":"string"},{"name":"SuperclassA1Subclasses","type":["null",{"type":"record","name":"SubclassA1","fields":[{"name":"SubclassA1","type":"string"}]},{"type":"record","name":"SubclassA2","fields":[{"name":"SubclassA2","type":"string"}]}]}]}},{"name":"SubclassA2List","type":{"type":"array","items":"SuperclassA1","java-class":"java.util.List"}},{"name":"stringSuperclassA1Map","type":{"type":"map","values":"SuperclassA1"}},{"name":"integerSuperclassA1Map","type":{"type":"array","items":{"type":"record","name":"Pair34255fab6d3d79ff","namespace":"org.apache.avro.reflect","fields":[{"name":"key","type":"int"},{"name":"value","type":"org.apache.avro.reflect.TestReflectPolymorphismData$.SuperclassA1"}]},"java-class":"java.util.Map"}}]}


> Avro Schema Generator to handle polymorphic types
> -------------------------------------------------
>
>                 Key: AVRO-1759
>                 URL: https://issues.apache.org/jira/browse/AVRO-1759
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.9.0
>            Reporter: Qiangqiang Shi
>
> Inheritance and polymorphism are widely used in Java projects and libraries. It'll make
people's life easier if Avro could detect classes' hierarchy and generate Avro schema according
to the hierarchy. 
> for example, for the following class:
> {code:java}
> public class TestReflectPolymorphismData {
> {
> public static class SuperclassA1 {
>     private String SuperclassA1;
>   }
>   public static class SubclassA1 extends SuperclassA1 {
>     private String SubclassA1;
>   }
>   public static class SubclassA2 extends SuperclassA1 {
>     private String SubclassA2;
>   }
> public static class SuperB1 {
>     private SubclassA1 SubclassA1;
>     private List<SubclassA2> SubclassA2List;
>     private Map<String, SuperclassA1> stringSuperclassA1Map;
>     private Map<Integer, SuperclassA1> integerSuperclassA1Map;
>   }
> }
> }
> {code}
> Avro should be able to generate a schema like the following one automatically :
> {"type":"record","name":"SuperB1","namespace":"org.apache.avro.reflect.TestReflectPolymorphismData$","fields":[{"name":"SubclassA1","type":{"type":"record","name":"SuperclassA1","fields":[{"name":"SuperclassA1","type":"string"},{"name":"SuperclassA1Subclasses","type":["null",{"type":"record","name":"SubclassA1","fields":[{"name":"SubclassA1","type":"string"}]},{"type":"record","name":"SubclassA2","fields":[{"name":"SubclassA2","type":"string"}]}]}]}},{"name":"SubclassA2List","type":{"type":"array","items":"SuperclassA1","java-class":"java.util.List"}},{"name":"stringSuperclassA1Map","type":{"type":"map","values":"SuperclassA1"}},{"name":"integerSuperclassA1Map","type":{"type":"array","items":{"type":"record","name":"Pair34255fab6d3d79ff","namespace":"org.apache.avro.reflect","fields":[{"name":"key","type":"int"},{"name":"value","type":"org.apache.avro.reflect.TestReflectPolymorphismData$.SuperclassA1"}]},"java-class":"java.util.Map"}}]}



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

Mime
View raw message