Avro schemas can represent Union types, but not abstract types. It does not make sense to serialize an abstract class, since its data members are not known. By definition, an abstract type does not define all of the possible sub types in advance, which presents another problem -- in order to make sense of serialized data, the universe of types serialized need to be known.
You can model an abstract type with union types with a little bit of work. For example, if you have type AbstractThing, with children Concrete1 and Concrete2, you can serialize these as a union of Concrete1 and Concrete2. When reading the element with this union, you will need to check the instance type at runtime and cast or if you know the super type is AbstractThing, you can blindly cast to AbstractThing. As new types are added, your schema will change to include more branches in the union. If you remove a type, you will need to provide a default in case the removed type is encountered while reading data. If you are using the Java Specific API the above will not work without wrapper classes that contain the hierarchy, and the ability to create these from the serialized types. Serialization deals only with data stored in member variables, and interfaces have no data. An Avro Protocol maps to a Java Interface, but it is never serialized, it represents a contract for exchanging serialized data. -Scott On 5/6/12 9:55 PM, "Gavin YAO" <gavin.ming....@gmail.com> wrote: > Hello: > I am very new to the Apache Avro community so I hope I am doing right > in just sending a mail to this address. > Is it possible to represent abstract as in Java language we can do it > by abstract class or interface? > > Thanks a lot! >