Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 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
http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getName().
 For example, an array of Strings might be represented either with the
schema:
  {"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
representation.

Doug
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB