0

I am new to Hadoop, and this is my first Hadoop program.

I am trying to create a Mapper class called WordMapper, but it throws be the below error.

The type WordMapper must implement the inherited abstract method Mapper.map(Object, Object, OutputCollector, Reporter)

public class WordMapper extends MapReduceBase implements Mapper 
{
    public void map(WritableComparable key, Writable values, OutputCollector output, Reporter reporter) throws IOException 
    {
        String line=values.toString();
        StringTokenizer tok=new StringTokenizer(line);
        while(tok.hasMoreTokens())
        {
            String t=tok.nextToken();
            output.collect(new Text(t), new IntWritable(1));
        }

    }

}

Can someone please tell me where i am going wrong and suggest to overcome the problem

Uday
  • 1,433
  • 10
  • 36
  • 57

2 Answers2

2

try to fulfill your Mapper parameter like this:

public class WCMapper extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable>

public void map(LongWritable key, Text values, OutputCollector output, Reporter reporter)
Athari
  • 33,702
  • 16
  • 105
  • 146
haku
  • 21
  • 2
1

You haven't provided any of the type parameters. Mapper is a generic interface; it's parameterized with type parameters for the input and output key and value types. Fill in K1, V1, K2, and V2 in the following code with the types you need:

public class WordMapper extends MapReduceBase implements Mapper<K1, V1, K2, V2> {
    public void map(K1 key,
                    V1 value,
                    OutputCollector<K2, V2> output,
                    Reporter reporter)
            throws IOException {
        whatever();
    }
}
user2357112
  • 260,549
  • 28
  • 431
  • 505