You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Saptarshi Guha <sa...@gmail.com> on 2012/11/06 05:12:49 UTC

Reading SequenceFiles throws Wrong key class r

Hello,

Sorry for the vague subject ....

I am writing some code using CDH 0.20.2-cdh3u4 to read RHBytesWritable
from a file(F) on the HDFS.

(1) The key/values present in F are class org.godhuli.rhipe.

RHBytesWritable

I am restructuring my code, so now, RHBytesWritable is in
org.godhuli.rhipe.io.RHBytesWritable.

Using this new refactored code, the following code throws this exception

wrong key class: org.godhuli.rhipe.io.RHBytesWritable is not class
org.godhuli.rhipe.RHBytesWritable

Object k=new Object();
Object v=new Object();
SequenceFile.Reader sqr = new SequenceFile.Reader(FileSystem.get(cfg) ,new
Path(pathname), cfg);
while( (nummax > 0 && count < nummax) || (nummax <=0 )){
    k = sqr.next(k);
    v = sqr.getCurrentValue(v);
    ....
}

So what options do i have left? Have a routine that copies
rhipe.RHB... to rhipe.io.RHBy.... ?

Re: Reading SequenceFiles throws Wrong key class r

Posted by Harsh J <ha...@cloudera.com>.
SequenceFiles unfortunately store the fully qualified classnames into
the serialized header. If you are "evolving" your classes to move to
another package, like you have done so by moving down into an io.*
package, you'll have to gracefully do it, by keeping the original
class, marked deprecated but extending the new location.

Otherwise, you need a utility that can hackily or elegantly migrate
the files to their new classname.

On Tue, Nov 6, 2012 at 9:42 AM, Saptarshi Guha <sa...@gmail.com> wrote:
> Hello,
>
> Sorry for the vague subject ....
>
> I am writing some code using CDH 0.20.2-cdh3u4 to read RHBytesWritable
> from a file(F) on the HDFS.
>
> (1) The key/values present in F are class org.godhuli.rhipe.
>
> RHBytesWritable
>
> I am restructuring my code, so now, RHBytesWritable is in
> org.godhuli.rhipe.io.RHBytesWritable.
>
> Using this new refactored code, the following code throws this exception
>
> wrong key class: org.godhuli.rhipe.io.RHBytesWritable is not class
> org.godhuli.rhipe.RHBytesWritable
>
> Object k=new Object();
> Object v=new Object();
> SequenceFile.Reader sqr = new SequenceFile.Reader(FileSystem.get(cfg) ,new
> Path(pathname), cfg);
> while( (nummax > 0 && count < nummax) || (nummax <=0 )){
>     k = sqr.next(k);
>     v = sqr.getCurrentValue(v);
>     ....
> }
>
> So what options do i have left? Have a routine that copies
> rhipe.RHB... to rhipe.io.RHBy.... ?



-- 
Harsh J

Re: Reading SequenceFiles throws Wrong key class r

Posted by Harsh J <ha...@cloudera.com>.
SequenceFiles unfortunately store the fully qualified classnames into
the serialized header. If you are "evolving" your classes to move to
another package, like you have done so by moving down into an io.*
package, you'll have to gracefully do it, by keeping the original
class, marked deprecated but extending the new location.

Otherwise, you need a utility that can hackily or elegantly migrate
the files to their new classname.

On Tue, Nov 6, 2012 at 9:42 AM, Saptarshi Guha <sa...@gmail.com> wrote:
> Hello,
>
> Sorry for the vague subject ....
>
> I am writing some code using CDH 0.20.2-cdh3u4 to read RHBytesWritable
> from a file(F) on the HDFS.
>
> (1) The key/values present in F are class org.godhuli.rhipe.
>
> RHBytesWritable
>
> I am restructuring my code, so now, RHBytesWritable is in
> org.godhuli.rhipe.io.RHBytesWritable.
>
> Using this new refactored code, the following code throws this exception
>
> wrong key class: org.godhuli.rhipe.io.RHBytesWritable is not class
> org.godhuli.rhipe.RHBytesWritable
>
> Object k=new Object();
> Object v=new Object();
> SequenceFile.Reader sqr = new SequenceFile.Reader(FileSystem.get(cfg) ,new
> Path(pathname), cfg);
> while( (nummax > 0 && count < nummax) || (nummax <=0 )){
>     k = sqr.next(k);
>     v = sqr.getCurrentValue(v);
>     ....
> }
>
> So what options do i have left? Have a routine that copies
> rhipe.RHB... to rhipe.io.RHBy.... ?



-- 
Harsh J

Re: Reading SequenceFiles throws Wrong key class r

Posted by Harsh J <ha...@cloudera.com>.
SequenceFiles unfortunately store the fully qualified classnames into
the serialized header. If you are "evolving" your classes to move to
another package, like you have done so by moving down into an io.*
package, you'll have to gracefully do it, by keeping the original
class, marked deprecated but extending the new location.

Otherwise, you need a utility that can hackily or elegantly migrate
the files to their new classname.

On Tue, Nov 6, 2012 at 9:42 AM, Saptarshi Guha <sa...@gmail.com> wrote:
> Hello,
>
> Sorry for the vague subject ....
>
> I am writing some code using CDH 0.20.2-cdh3u4 to read RHBytesWritable
> from a file(F) on the HDFS.
>
> (1) The key/values present in F are class org.godhuli.rhipe.
>
> RHBytesWritable
>
> I am restructuring my code, so now, RHBytesWritable is in
> org.godhuli.rhipe.io.RHBytesWritable.
>
> Using this new refactored code, the following code throws this exception
>
> wrong key class: org.godhuli.rhipe.io.RHBytesWritable is not class
> org.godhuli.rhipe.RHBytesWritable
>
> Object k=new Object();
> Object v=new Object();
> SequenceFile.Reader sqr = new SequenceFile.Reader(FileSystem.get(cfg) ,new
> Path(pathname), cfg);
> while( (nummax > 0 && count < nummax) || (nummax <=0 )){
>     k = sqr.next(k);
>     v = sqr.getCurrentValue(v);
>     ....
> }
>
> So what options do i have left? Have a routine that copies
> rhipe.RHB... to rhipe.io.RHBy.... ?



-- 
Harsh J

Re: Reading SequenceFiles throws Wrong key class r

Posted by Harsh J <ha...@cloudera.com>.
SequenceFiles unfortunately store the fully qualified classnames into
the serialized header. If you are "evolving" your classes to move to
another package, like you have done so by moving down into an io.*
package, you'll have to gracefully do it, by keeping the original
class, marked deprecated but extending the new location.

Otherwise, you need a utility that can hackily or elegantly migrate
the files to their new classname.

On Tue, Nov 6, 2012 at 9:42 AM, Saptarshi Guha <sa...@gmail.com> wrote:
> Hello,
>
> Sorry for the vague subject ....
>
> I am writing some code using CDH 0.20.2-cdh3u4 to read RHBytesWritable
> from a file(F) on the HDFS.
>
> (1) The key/values present in F are class org.godhuli.rhipe.
>
> RHBytesWritable
>
> I am restructuring my code, so now, RHBytesWritable is in
> org.godhuli.rhipe.io.RHBytesWritable.
>
> Using this new refactored code, the following code throws this exception
>
> wrong key class: org.godhuli.rhipe.io.RHBytesWritable is not class
> org.godhuli.rhipe.RHBytesWritable
>
> Object k=new Object();
> Object v=new Object();
> SequenceFile.Reader sqr = new SequenceFile.Reader(FileSystem.get(cfg) ,new
> Path(pathname), cfg);
> while( (nummax > 0 && count < nummax) || (nummax <=0 )){
>     k = sqr.next(k);
>     v = sqr.getCurrentValue(v);
>     ....
> }
>
> So what options do i have left? Have a routine that copies
> rhipe.RHB... to rhipe.io.RHBy.... ?



-- 
Harsh J