java.util.NoSuchElementException:spark.executor.cores

时间:2016-07-26 14:18:53

标签: scala apache-spark

我试图用这段代码计算每个执行器中的核心数:

sqlContext.sparkContext.getConf.get("spark.executor.cores").toInt

但是,我收到此错误:

spark.executor.cores
java.util.NoSuchElementException: spark.executor.cores
    at org.apache.spark.SparkConf$$anonfun$get$1.apply(SparkConf.scala:193)
    at org.apache.spark.SparkConf$$anonfun$get$1.apply(SparkConf.scala:193)
    at scala.Option.getOrElse(Option.scala:120)

为什么会失败?

1 个答案:

答案 0 :(得分:0)

这有效:

sqlContext.sparkContext.getConf.getInt("spark.executor.cores", -1)