hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bibek Paudel <eternalyo...@gmail.com>
Subject help with rewriting hadoop java code for new API: getPos() and getCounter()
Date Tue, 26 Oct 2010 20:49:21 GMT
[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 the getCounter() method ? For example,
the old code is as following:
//import org.apache.hadoop.mapred.RunningJob;
RunningJob job = JobClient.runJob(conf);
Counters c = job.getCounters();
long cnt = c.getCounter(EnumType.A);

I tried to rewrite it as:
//import org.apache.hadoop.mapreduce.Job;
Configuration conf = new Configuration();
Job job = new Job(conf);
Counters c = job.getCounters();
long cnt = c.getCounter(EnumType.A);

I get the error: The method getCounter(MyClassName.EnumType) is
undefined for the type Counters

2. What is the equivalent of getPos() method [0] of RecordReader ?

I read that in 0.20, the getPos() methos is no longer there, 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

Mime
View raw message