You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by Bibek Paudel <et...@gmail.com> on 2010/10/27 11:37:38 UTC
help with rewriting hadoop java code for new API: RecordReader getPos()
[Apologies for cross-posting]
HI all,
I am rewriting a hadoop java code for the new (0.20.2) API- the code
was originally written for versions <= 0.19.
1. What is the equivalent of getPos() method [0] of RecordReader ?
I read that in 0.20, the getPos() methos is no longer there [1], but what
am I supposed to replace it with?
For example, in a map function, I have (RecordReader<IntWritable,
CustomInput> input, Context context) and in the function body, I have:
long pos = -1;
pos = input.getPos();
while(input.next(key, value)){
//some code here
}
and I get the error: The method getPos() is undefined for the type
RecordReader<IntWritable,CustomInput>
Any pointers or help will be highly appreciated.
Thanks,
Bibek
[0] http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapred/RecordReader.html#getPos%28%29
[1] http://www.slideshare.net/sh1mmer/upgrading-to-the-new-map-reduce-api
Re: help with rewriting hadoop java code for new API: RecordReader getPos()
Posted by Jeff Zhang <zj...@gmail.com>.
pos can been get through InputStream wrapped in RecordReader. You can
refer to org.apache.hadoop.mapreduce.lib.input.LineRecordReader for
details.
On Wed, Oct 27, 2010 at 5:37 PM, Bibek Paudel <et...@gmail.com> wrote:
> [Apologies for cross-posting]
>
> HI all,
> I am rewriting a hadoop java code for the new (0.20.2) API- the code
> was originally written for versions <= 0.19.
>
> 1. What is the equivalent of getPos() method [0] of RecordReader ?
>
> I read that in 0.20, the getPos() methos is no longer there [1], but what
> am I supposed to replace it with?
>
> For example, in a map function, I have (RecordReader<IntWritable,
> CustomInput> input, Context context) and in the function body, I have:
> long pos = -1;
> pos = input.getPos();
> while(input.next(key, value)){
> //some code here
> }
>
> and I get the error: The method getPos() is undefined for the type
> RecordReader<IntWritable,CustomInput>
>
> Any pointers or help will be highly appreciated.
>
> Thanks,
> Bibek
>
> [0] http://hadoop.apache.org/common/docs/r0.20.1/api/org/apache/hadoop/mapred/RecordReader.html#getPos%28%29
> [1] http://www.slideshare.net/sh1mmer/upgrading-to-the-new-map-reduce-api
>
--
Best Regards
Jeff Zhang