I am new on MapReduce applications. I'm simply trying to find words' length on my data set and categorize them as tiny, little, med, huge according to their length and in the end, I want to see the total number how many words are tiny, little, med or huge on my data set in Java but I have a problem on implementing reducer. When I execute jar file on Hadoop cluster, it doesn't return any result. If somebody give a hand to me, I will be grateful. Here is the reducer code that I try to execute but have lots of error I guess.
public class WordSizeReducer extends Reducer<IntWritable, IntWritable, Text, IntWritable> {
private IntVariable result = new IntVariable();
IntWritable tin, smal, mediu,bi;
int t, s, m, b;
int count;
Text tiny, small, medium, big;
public void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException{
for (IntWritable val:values){
if(val.get() == 1){
tin.set(t);
t++;
}
else if(2<=val.get() && val.get()<=4){
smal.set(s);
s++;
}
else if(5<=val.get() && val.get()<=9){
mediu.set(m);
m++;
}
else if(10<=val.get()){
bi.set(b);
b++; }
}
context.write(tiny, tin);
context.write(small, smal);
context.write(medium, mediu);
context.write(big, bi);
}
}
public class WordSizeMapper extends Mapper<LongWritable, Text, IntWritable, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private IntWritable wordLength = new IntWritable();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
wordLength.set(tokenizer.nextToken().length());
context.write(wordLength, one);
}
}
}