avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: using strings instead of utf8
Date Mon, 29 Oct 2012 21:37:36 GMT
On Fri, Oct 19, 2012 at 2:57 PM, Koert Kuipers <koert@tresata.com> wrote:
> how do i tell (generic) avro to use strings for values instead of it's own
> utf8 class?
>
> i saw a way of doing it by modifying the schemas (adding a property). i also
> saw mention of a way to do it if you use maven (which i don't).

The property is "avro.java.string".  If the value is "String" then a
java.lang.String is returned.  In other words, if the reading schema
is {"type":"string", "avro.java.string":"String"} then String will be
returned instead of Utf8.

The Maven technique causes the specific compiler to emit this for all
String schemas.  This is done by adding
<stringType>String</stringType> to your pom.xml.

> is there a generic way to do this? like a system property perhaps? or a
> static method that i call to change the default?

No.  A static switch would break other applications that don't expect
this.  However one can override the readString() method in either the
Decoder or the DatumReader to achieve this.

Doug

Mime
View raw message