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

Switch to Plain View
Avro >> mail # user >> Re: runtime error when casting Array<String> to String[]

Sameer Deokule 2012-06-29, 02:02
Copy link to this message
Re: runtime error when casting Array<String> to String[]
On Thu, Jun 28, 2012 at 7:02 PM, Sameer Deokule <[EMAIL PROTECTED]> wrote:
>   Is mapping of avro arrays to java arrays instead of lists, still being
> planned?

This is possible in Avro 1.7 if you use ReflectDatumReader and the
array schema includes either "java-class" or a "java-element-class"
attribute.  The "java-class" attribute should be an array class name
e.g., "[I" for an int[] and "[Ljava.lang.String" for String[] -- see
 For example, an array of Strings might be represented either with the
  {"type":"array", "items":"string", "java-class":"[Ljava.lang.String"}
or with:
  {"type":"array", "items":"string", "java-element-class":"java.lang.String"}

Note that ReflectDatumReader is a superclass of SpecificDatumReader
and GenericDatumReader, so in addition to reading reflected records,
it can also correctly read records defined by the specific compiler or
if no class exists for a record it will use the generic