不可序列化的任务:java.io.NotSerializableException仅在类
不可序列化的任务:java.io.NotSerializableException:测试
object working extends App { val list = List(1,2,3) val rddList = Spark.ctx.parallelize(list) //calling function outside closure val after = rddList.map(someFunc(_)) def someFunc(a:Int) = a+1 after.collect().map(println(_))}
object NOTworking extends App { new testing().doIT}//adding extends Serializable wont helpclass testing { val list = List(1,2,3) val rddList = Spark.ctx.parallelize(list) def doIT = { //again calling the fucntion someFunc val after = rddList.map(someFunc(_)) //this will crash (spark lazy) after.collect().map(println(_)) } def someFunc(a:Int) = a+1}