New to Hadoop! I'm trying to modify the code of wordcount program to only output words that start with "a", for example.

I've modified the mapper method code, but for unknown reasons it stills outputs all the words in the input file. The rest of the code is unchanged and can be found at

public void map(Object key, Text value, Context context
                    ) throws IOException, InterruptedException {
        Text word = new Text();
        StringTokenizer itr = new StringTokenizer(value.toString());
        while (itr.hasMoreTokens()) {
            String currentWord = itr.nextToken();
            if(currentWord.startsWith("a")) {
                context.write(word, new IntWritable(1));

The output file still contains all the words. I was only expecting words starting with letter - a.

Any help will be appreciated. Thanks in advance.

0 Answers