如何将arraylist转换为元组?

时间:2015-07-17 04:29:26

标签: python apache-spark

: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 5.0 failed 1 times, most recent failure: Lost task 0.0 in stage 5.0 (TID 5, localhost): org.apache.spark.SparkException: Data of type java.util.ArrayList cannot be used

我的rdd是由一个包含密钥" mylist"的avro文件制作的。我如何更改它,以便它使用元组元组代替?有没有办法创建一个新的RDD,但将当前的地图arraylist转换为地图元组的元组而不是地图的arraylist?

即。而不是[{"a":"vala", "a1":"vala1"},{"b":"valb", "b1":"valb1"}],将其更改为(({"a":"vala", "a1":"vala1"},{"b":"valb","b1":"valb1"}))

1 个答案:

答案 0 :(得分:0)

您应该可以在列表中拨打tuple

>>> tuple([{"a":"vala", "a1":"vala1"},{"b":"valb", "b1":"valb1"}])
({'a': 'vala', 'a1': 'vala1'}, {'b1': 'valb1', 'b': 'valb'})