if(value[0].equals("2")){
grandparentList.add(value[2]);
continue;
}
}
if((!grandchildList.isEmpty())&&(!grandparentList.isEmpty())){
for(String child:grandchildList){
for(String parent:grandparentList){
context.write(new Text(child), new Text(parent));
}
}
}
}
}[/mw_shl_code]
按照这个程序,跑出来的结果尽然是这样:
grandchild grandparent
Jack Jack
Jack Jack
Jack Jack
Jack Jack
Lucy Lucy
Lucy Lucy
Lucy Lucy
Lucy Lucy
Terry Terry
Terry Terry