soujanya
soujanya

Reputation: 29

Mapper and Reducer interfaces not considered

This is my mapper function header line

public static class PageMapper extends Mapper<Text, Text, Text, Text>

and this is my Reducer function header

public static class PageReducer extends Reducer`<Text, Text, Text, Text>

While compiling the code

PageRank.java:30: error: no interface expected here

    extends Mapper <Object, Text, Text, Text>

PageRank.java:61: error: no interface expected here

public static class PageReducer extends Reducer<Text, Text, Text, Text>

Why is it not accepting the Mapper and Reducer here. Can anyone help please

Upvotes: 0

Views: 789

Answers (2)

Hafedh M.
Hafedh M.

Reputation: 1

What is confusing is that the API contains both: 1) the class org.apache.hadoop.mapreduce.Reducer and 2) the interface org.apache.hadoop.mapred.Reducer

AND

1) the class does not implement the interface 2) the method reduce in the class has a different signature from the interface 3) the MapReduce tutorial uses the class Reducer, and not the interface.

My guess is that one of the two should be deprecated and it should be mentioned somewhere what is the best practice: 1) to implement the interface org.apache.hadoop.mapred.Reducer, or 2) to extend the class org.apache.hadoop.mapreduce.Reducer

Upvotes: 0

SSC
SSC

Reputation: 3008

First of all, Mapper and Reducer are interfaces, not classes. You implement interfaces, not classes. Other than that, just keep in mind that both Mapper and Reducer interfaces implement Generics and expect two key-value pairs. Forexample:

Mapper<Key1,Value1,Key2,Value2>

You can read more about Mapper and Reducer from here:

org.apache.hadoop.mapred.Mapper

org.apache.hadoop.mapred.Reducer

Upvotes: 3

Related Questions