Comparison method violates its general contract!
程序员文章站
2024-02-23 08:05:58
...
在使用spark RDD中,需要进行二次排序,二次排序需要使用到scala List的sortWith(compare),需传递一个比较函数compare给sortWith,这个时候会报如标题所示的错误。
val rdd1 = rdd.groupByKey().sortByKey(true).map(x => (x._1,x._2.toList.sortWith(timeCompare)));
这个错误是jvm1.6和jvm1.7版本不一样带来的bug,来龙去脉参考:Comparison method violates its general contract!
根据参考文档,需要强制jvm使用jdk1.6的数组排序策略,所以需要传递jvm参数,如下:
sparkConf.set("spark.executor.extraJavaOptions", "-Djava.util.Arrays.useLegacyMergeSort=true");
转载于:https://my.oschina.net/cjun/blog/650466
上一篇: redisgo库小试牛刀
推荐阅读
-
Comparison method violates its general contract
-
Comparison method violates its general contract!
-
Comparison method violates its general contract!
-
Comparison method violates its general contract
-
Comparison method violates its general contract!
-
Comparison method violates its general contract!
-
Comparison method violates its general contract!
-
Comparison method violates its general contract
-
java中排序报:Comparison method violates its general contract异常的解决
-
java中排序报:Comparison method violates its general contract异常的解决