Spark - Task not serializable: How to work with complex map closures that call outside classes/objects?

后端 未结 2 1988
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 19:44

Take a look at this question: Scala + Spark - Task not serializable: java.io.NotSerializableExceptionon. When calling function outside closure only on classes not objects.

2条回答
  •  逝去的感伤
    2021-01-31 20:37

    In case of using Java API you should avoid anonymous class when passing to the mapping function closure. Instead of doing map( new Function) you need a class that extends your function and pass that to the map(..) See: https://yanago.wordpress.com/2015/03/21/apache-spark/

提交回复
热议问题