I am not able to return flaot values after calculating average of numbers to output.collect..can anyone please help me??
public static class MapClass extends MapReduceBase implements Mapper {
private Text word = new Text();
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> output,
Reporter reporter) throws IOException {
String line = value.toString();
String num = Integer.parseInt(num);
IntWritable one = new IntWritable(num);
word.set(“key”);
output.collect(word, one);
}
}
public static class Reduce extends MapReduceBase implements Reducer {
public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, IntWritable> output,
Reporter reporter) throws IOException {
int sum = 0;
int count=0;
int avg=0;
while (values.hasNext()) {
sum += values.next().get();
count++;
}
avg=sum/count;
output.collect(key, new IntWritable(avg));
}
}