在尝试合并并保存RDD时,我得到了一个NPE.
代码在本地工作,并在scala shell中的集群上工作,但在将其作为作业提交到集群时会引发错误.
我已经尝试使用take()打印输出以查看rdd是否包含一些空数据,但这会引发相同的错误 - 痛苦,因为它在shell中正常工作.
我正在保存到HDFS并且在变量中有完整的url路径 - 在MLLib训练阶段,模型可以很好地保存这个方法.
任何想法非常感谢!
Scala代码(整体预测功能):
//Load the Random Forest
val rfModel = RandomForestModel.load(sc, modelPath)
//Make the predictions - Here the label is the unique ID of the point
val rfPreds = labDistVect.map(p => (p.label, rfModel.predict(p.features)))
//Collect and save
println("Done Modelling, now saving preds")
val outP = rfPreds.coalesce(1,true).saveAsTextFile(outPreds)
println("Done Modelling, now saving coords")
val outC = coords.coalesce(1,true).saveAsTextFile(outCoords)
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage …Run Code Online (Sandbox Code Playgroud)