3
没有有效的构造这是我的代码:的火花
class FNNode(val name: String)
case class Ingredient(override val name: String, category: String) extends FNNode(name)
val ingredients: RDD[(VertexId, FNNode)] =
sc.textFile(PATH+"ingr_info.tsv").
filter(! _.startsWith("#")).
map(line => line.split('\t')).
map(x => (x(0).toInt ,Ingredient(x(1), x(2))))
而且有当我定义这些变量没有错误。然而,当试图执行它:
ingredients.take(1)
我得到
org.apache.spark.SparkException: Job aborted due to stage failure: Exception while getting task result: java.io.InvalidClassException: $iwC$$iwC$Ingredient; no valid constructor
at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1431)
at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1419)
看来,这可能是每答案here涉及到序列化的问题。但是,如果这确实是一个序列化问题,我不知道如何解决这个问题。
我沿着this书中的代码按照他们的方式,所以我会认为这应该至少在某个时间点工作?
FNNode必须有一个案例类以及除非我想。 – eliasah
不幸的是,我得到这个:“error:case class Ingredient has case ancestor $ iwC。$ iwC.FNNode,但是case-to-case inheritance is prohibited。为了克服这个限制,使用提取器在非叶节点上模式匹配” – elelias
你可以试试,是否有助于让FNNode扩展Serializable? –