public class SumReducer extends Reducer<Text, Text, Text, Text> {
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> l1=new ArrayList<String>();
List<String> l2=new ArrayList<String>();
List<String> l3=new ArrayList<String>();
List<String> l4=new ArrayList<String>();
@Override
public void reduce(Text key, Iterable<Text> values, Context context)
throws IOException, InterruptedException
{
int j=0;
String[] wordCount = new String[100];
List<String> Final = new ArrayList<String>();
String mapop = "";
for (Text value : values) {
wordCount[j] =value.toString();
j++;
}
for(int i=0;i<j;i++){
//Final= Final+","+wordCount[i];
Final.add(wordCount[i]);
}
String key1=key.toString();
map.put(key1, Final);
l1.add("1");
l2=(map.get("1"));
int total_nodes=l2.size();
for(int i=0;i<total_nodes;i++)
{
if(l2.size()!=1)
{
l1.add(l2.get(0));
**l3=map.get(l2.get(0));**
**int cs=l3.size()**;//---------------NULLPOINTER EXCEPTION ON THIS LINE
for(int e=1;e<l2.size();e++)
{
for(int k=0;k<cs;k++)
{
String keymap=l2.get(e);
if(keymap==l3.get(k)){
l4.add(keymap);
//System.out.println(l4);
break;
}
}
}
}
This code runs perfectly in java but throws NULL pointer exception in mapreduce. Value of l3(list) is not getting initialized at all. I am trying to implement bruteforce algorithm for finding cliques. The program has static inputs with 5 nodes in a graph all connected to each other. This is not the whole program but just a snippet of the code where the error is shown.