You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Koert Kuipers <ko...@tresata.com> on 2011/12/01 20:24:19 UTC

override avro generic representation

Is there a way to override the avro generic representation, or perhaps an
easy way to create my own?
For example, for FIXED i would like Byte[] instead of ByteBuffer, for
STRING i would prefer String over CharArray, for arrays i would like to
have a List instead of a Collection, etc.

Right now i do a translation from the generic representation to my internal
representation and then back, which is fragile and inefficient.

Thanks! Koert

Re: override avro generic representation

Posted by Doug Cutting <cu...@apache.org>.
On 12/01/2011 11:24 AM, Koert Kuipers wrote:
> Is there a way to override the avro generic representation, or perhaps
> an easy way to create my own?
> For example, for FIXED i would like Byte[] instead of ByteBuffer, for
> STRING i would prefer String over CharArray, for arrays i would like to
> have a List instead of a Collection, etc.

To change the representation for fixed, subclass GenericData, override
isFixed() and getFixedSchema(), subclass GenericDatumReader overriding
readFixed() and subclass GenericDatumWriter overriding writeFixed().

Doug