0
鍵排序我JavaPairRDD類型的關鍵Tuple2<Integer, Integer>
在apache的火花JavaPairRDD
我希望通過我的鑰匙JavaPairRDD排序所以我寫了這樣一個比較:
JavaPairRDD<Tuple2<Integer, Integer>, Integer> Rresult=result.sortByKey(new Comparator<Tuple2<Integer, Integer>>() {
@Override
public int compare(Tuple2<Integer, Integer> o1, Tuple2<Integer, Integer> o2) {
if(o1._1()==o2._1())
return o1._2()-o2._2();
return o1._1()-o2._1();
}
},true);
這個排序值通過第一次進入元組,如果它們與第二項相同。
但我收到以下錯誤堆棧:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.. scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at org.apache.spark.scheduler.DAGScheduler.handleTaskCompletion(DAGScheduler.scala:1083)
at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1447)
at
at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at java.io.ObjectStrea