The mapper outputs the value only once. But when i checked the combiner is having the value twice. This is really strange to me.
Pls help.
Module of map code from where output is sent:
for(int i = 0; i<alcmapi.size(); i++)
{
int section = 0;
for(int j = 0; j<alcmapj.size(); j++)
{
if(!alcmapi.get(i).getid().equals(alcmapj.get(j).getid()))
{
int fi = Integer.parseInt(alcmapi.get(i).getField());
int fj = Integer.parseInt(alcmapj.get(j).getField());
ArrayList<CustomMap> al = new ArrayList<CustomMap>();
al.add(new CustomMap(alcmapi.get(i).getid(), fi));
al.add(new CustomMap(alcmapj.get(j).getid(), fj));
if(fi<fj)
{
section = fi;
}
else
{
section = fj;
}
Collections.sort(al);
{
output.collect(new Text(t+" "+al.get(0).getid()), new Text(al.get(1).getid()+" "+section));
}
}
}
}
In combiner:
I see that the value corresponding to a key appears doubled when I check here:
while(values.hasNext()){
String val = values.next().toString();
System.out.println("val:"+val);
}
Thanks in advance!
Looks like you test all elements against all other elements. For example, if elements 3 and 5 meet the criteria then you’d write out the pair once for i=3, j=5 and once again for i=5, j=3.
I suggest you change your inner loop to: