JavaPairRDD<Tuple2<String, String>, Integer> productPairCount = productPairSS.mapToPair(
new PairFunction<Tuple2<String, String>, Tuple2<String, String>, Integer>(){
public Tuple2<Tuple2<String, String>, Integer> call(Tuple2<String, String> x){
return new Tuple2(x,1);
}
}
).reduceByKey(new Function2<Integer, Integer, Integer>(){
public Integer call(Integer x, Integer y){return x+y;}
});
new PairFunction<Tuple2<String, String>, Tuple2<String, String>, Integer>(){
public Tuple2<Tuple2<String, String>, Integer> call(Tuple2<String, String> x){
return new Tuple2(x,1);
}
}
).reduceByKey(new Function2<Integer, Integer, Integer>(){
public Integer call(Integer x, Integer y){return x+y;}
});