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

Switch to Plain View
Avro >> mail # user >> using custom builders

Joel VanderWerf 2012-05-17, 18:54
Copy link to this message
Re: using custom builders
On 05/17/2012 11:54 AM, Joel VanderWerf wrote:
> I'd like to subclass the avro-generated classes.
> Is it possible to tell avro to deserialize using a custom builder that
> instantiates my subclasses?
> There are some hints in the source code that this might be possible, but
> what I'd really like is a small, working example...

This may be what I'm looking for:


The getClass() method perhaps can be overridden to map incoming record
class names to java classes. Not sure if this is the right way to do it
though. There's also a getClassName() which might be a better method to

Any thoughts?

What we are trying to do is emulate JAXB's ObjectFactory
functionality[1], which lets you specify which subclasses of the
generated classes are used for deserialization.

[1] http://jaxb.java.net/guide/Adding_behaviors.html
Doug Cutting 2012-06-06, 17:16