Spark NullPointerException mit saveAsTextFile

Ich erhalte eine NPE, wenn ich versuche, eine RDD zusammenzuführen und zu speichern.

Code arbeitet lokal,un funktioniert auf dem Cluster in der Scala-Shell, löst jedoch den Fehler aus, wenn es als Job an den Cluster gesendet wird.

Ich habe versucht, mit take () auszudrucken, um zu sehen, ob die rdd leere Daten enthält, aber das löst den gleichen Fehler aus - Schmerz, weil es in der Shell funktioniert.

Ich speichere in HDFS und habe den vollständigen URL-Pfad in der Variable - Modell speichere mit dieser Methode gut während der MLLib-Trainingsphase.

Alle Ideen sehr geschätzt!

Scala Code (gesamte Vorhersagefunktion):

//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)

Stack Trace:

    Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 6.0 failed 4 times, most recent failure: Lost task 0.3 in stage 6.0 (TID 40, XX.XX.XX.XX): java.lang.NullPointerException
    at GeoDistPredict1$anonfun$38.apply(GeoDist1.scala:340)
    at GeoDistPredict1$anonfun$38.apply(GeoDist1.scala:340)
    at scala.collection.Iterator$anon$11.next(Iterator.scala:328)
    at scala.collection.Iterator$anon$10.next(Iterator.scala:312)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)

Antworten auf die Frage(2)

Ihre Antwort auf die Frage