Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> how to implement inheritance in Avro


Copy link to this message
-
how to implement inheritance in Avro
Hi all,

I've been struggling to get some sort of inheritance model to work with Avro but I've not been very successful at it. So maybe someone in hear can give me a pointer. What I've been trying to do is to define schemas like this
{"namespace": "com.test",
 "type": "record",
 "name": "Shape",
 "fields": [
     {"name": "colour", "type": "string"}
 ]
}

{"namespace": "com.test",
 "type": "record",
 "name": "Circle",
 "fields": [
     {"name": "radius", "type": "int"},
     {"name": "super", "type": "com.test.Shape"}
 ]
}

{"namespace": "com.test",
 "type": "record",
 "name": "Square",
 "fields": [
     {"name": "width", "type": "int"},
     {"name": "super", "type": "com.test.Shape"}
 ]
}

When I try to generate classes from this I get "org.apache.avro.SchemaParseException: "com.test.Shape" is not a defined name". So what is a defined name and where I define it? I tried to put everything into the same file but that didn't work. I also tried to play around with unions but couldn't get the schema syntax right. Any help with this would be greatly appreciated and also other patterns for implementing inheritance with Avro are interesting.

Thanks for any help!!

-Mika
+
Doug Cutting 2013-05-28, 22:41
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB