[
https://issues.apache.org/jira/browse/AVRO-1763?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Qiangqiang Shi updated AVRO-1763:
---------------------------------
Description:
Inheritance and polymorphism are widely used in Java libraries. If multiple
sophisticated Avro schema generator can be added to Avro, users can generate
Avro schema easily for classes in complex context, third-party code and legacy
code.
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}
It'll be good if Avro can provide a schema generator to generate a schema like
the following automatically for class SuperB1 :
{code:json}
{
"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"
}
}
]
}
{code}
related story: AVRO-1568
was:
Inheritance and polymorphism are widely used in Java libraries. If multiple
sophisticated Avro schema generator can be added to Avro, users can generate
Avro schema easily for classes in complex context, third-party code and legacy
code.
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}
It'll be good if Avro can provide a schema generator to generate a schema like
the following automatically for class SuperB1 :
{code:json}
{
"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"}}]}
{code}
related story: AVRO-1568
> Avro Schema Generator to handle polymorphic types
> -------------------------------------------------
>
> Key: AVRO-1763
> URL: https://issues.apache.org/jira/browse/AVRO-1763
> Project: Avro
> Issue Type: Improvement
> Affects Versions: 1.9.0
> Reporter: Qiangqiang Shi
>
> Inheritance and polymorphism are widely used in Java libraries. If multiple
> sophisticated Avro schema generator can be added to Avro, users can generate
> Avro schema easily for classes in complex context, third-party code and
> legacy code.
> 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}
> It'll be good if Avro can provide a schema generator to generate a schema
> like the following automatically for class SuperB1 :
> {code:json}
> {
> "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"
> }
> }
> ]
> }
> {code}
> related story: AVRO-1568
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)