Member since
12-11-2018
2
Posts
0
Kudos Received
0
Solutions
12-12-2018
01:15 PM
Hello everybody, I have the same problem and i follow the instruction above. Here the result : What is the problem ?? Thanks a lot !
... View more
12-11-2018
07:53 AM
Hello everybody, I'm a beginner and i follow a tutorial on cloudera to do my first MapReduce but i have a problem when i run my Jar file : Error: java.lang.NullPointerException at MonReducer.reduce(MonReducer.java:23) at MonReducer.reduce(MonReducer.java:1) at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171) at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:627) at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:389) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:415) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1917) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Okay, so my problem is my reducer but i can't find the solution and i don't know how to debug it. My Reducer looks like : import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class MonReducer extends Reducer<Text, Text, Text, Text> {
@Override
protected void reduce(Text key, Iterable<Text> values,
Reducer<Text, Text, Text, Text>.Context context)
throws IOException, InterruptedException {
final Map<String, Integer> occurences = new HashMap<String, Integer>();
for (Text value : values) {
String sValue = value.toString();
occurences.put(sValue,
occurences.containsKey(sValue) ? occurences.get(value) + 1 : 1);
}
List<String> produits = new ArrayList<String>(occurences.keySet());
Collections.sort(produits, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return occurences.get(o2) - occurences.get(o1);
}
});
String sProduits = "";
for (String produit : produits) {
sProduits += produit + ",";
}
context.write(key, new Text(sProduits));
}
} Did you see any errors ? How can i debug it ? Thank you !!
... View more