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? –