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 >> Type cast exception


+
Jaydeep Ayachit 2010-04-26, 14:59
+
Scott Carey 2010-04-27, 19:48
+
TrevniUser 2013-07-02, 17:05
Copy link to this message
-
Re: Type cast exception
Could this be AVRO-1240?  What version of Avro are you using?

https://issues.apache.org/jira/browse/AVRO-1240

Doug

On Tue, Jul 2, 2013 at 10:05 AM, TrevniUser <[EMAIL PROTECTED]> wrote:
> I am facing this same issue while using SortedKeyValueFile. Could you please
> provide some pointers why in the first place is GenericRecord being picked
> up and not SpecificRecord?
>
> @Test
>     public void testSortedKeyValueFile() throws IOException {
>         Path filePath = new Path(test.getMethodName());
>
>         Schema keySchema = ReflectData.get().getSchema(Long.class);
>         Schema valSchema > ReflectData.get().getSchema(DataSinkChangeLogContent.class);
>
>         SortedKeyValueFile.Writer.Options opts = new Options();
>         opts.withKeySchema(keySchema);
>         opts.withValueSchema(valSchema);
>         opts.withConfiguration(conf);
>         opts.withPath(filePath);
>         SortedKeyValueFile.Writer<Long, DataSinkChangeLogContent> writer > new SortedKeyValueFile.Writer<Long, DataSinkChangeLogContent>(
>                 opts);
>         for (long i = 0; i < 10; i++) {
>             writer.append(i, new DataSinkChangeLogContent(eType.toString(),
> eKey.toString(), i, 15L));
>         }
>         writer.close();
>
>         SortedKeyValueFile.Reader.Options readerOpts = new
> SortedKeyValueFile.Reader.Options();
>         readerOpts.withKeySchema(keySchema);
>         readerOpts.withValueSchema(valSchema);
>         readerOpts.withConfiguration(conf);
>         readerOpts.withPath(filePath);
>         SortedKeyValueFile.Reader<Long, DataSinkChangeLogContent> reader > new SortedKeyValueFile.Reader<Long, DataSinkChangeLogContent>(
>                 readerOpts);
>         Iterator<AvroKeyValue<Long, DataSinkChangeLogContent>> i = null;
>         if (reader.get(5L) != null) {
>             i = reader.iterator();
>         }
>         while (i != null && i.hasNext()) {
>             AvroKeyValue<Long, DataSinkChangeLogContent> keyValue > i.next();
>             System.out.println("---------------------------- Clock: " +
> keyValue.getValue());
>         }
> *        DataSinkChangeLogContent e = reader.get(5L);* // FAILS AT THIS LINE
>         reader.close();
>     }
>
> EXCEPTION:
>
> java.lang.ClassCastException: org.apache.avro.generic.GenericData$Record
> cannot be cast to com.abc.kepler.datasink.DataSinkChangeLogContent
>         at
> com.abc.kepler.datasink.hdfs.HDFSDataSinkChangeLogScannerTest.testSortedKeyValueFile(HDFSDataSinkChangeLogScannerTest.java:926)
>
>
>
> --
> View this message in context: http://apache-avro.679487.n3.nabble.com/Type-cast-exception-tp756884p4027727.html
> Sent from the Avro - Users mailing list archive at Nabble.com.
+
TrevniUser 2013-07-02, 17:33
+
Doug Cutting 2013-07-02, 17:38
+
TrevniUser 2013-07-02, 17:45
+
Doug Cutting 2013-07-02, 20:06
+
TrevniUser 2013-07-02, 20:12
+
TrevniUser 2013-07-02, 19:15
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