Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # dev >> Support for inheritance in avro IDL?

Alexandre Normand 2013-04-11, 21:51
Copy link to this message
Re: Support for inheritance in avro IDL?
I would not be opposed to adding inheritance in IDL.

FWIW, another way to represent sub-types is through a union field in
the "super" record, i.e.:

record Shape {
  int x;
  int y;
  union subFields { CircleFields, SquareFields }

record CircleFields {
  int radius;

record SquareFields {
  int size;

Then you only need to use instanceof and casts for operations that are
specific to sub-types.


On Thu, Apr 11, 2013 at 2:51 PM, Alexandre Normand
> Hey,
> I'm wondering what you guys think of adding support for inheritance in avro IDL. We're starting to see unions of different types in our code and they mostly have the same fields. We're basically using unions to do inheritance except that the code that uses it remains cumbersome. The client code needs to do instanceof just to cast to the proper type in order to retrieve a value that is actually present in all types of the union.
> It seems like this could be hidden from client by just creating a union of all types extending a parent type defined for a field and generating sources with that type.
> Any thoughts?
> --
> Alex
Alexandre Normand 2013-04-24, 03:57