Spark 源码系列 - SparkConf本质
作者:互联网
目录
结论
SparkConf设置的key / value 保存在SparkConf名为settings的变量中,该变量类型为ConcurrentHashMap
- SparkConf的setXX方法, 封装了特定的属性名和值存储到map中
- SparkConf的set方法,直接将属性名和值存储到map中。
属性 | SparkConf提供的封装方法 |
---|---|
spark.master | setMaster |
spark.app.name | setAppName |
spark.default.parallelism | 无 |
代码
val conf = new SparkConf()
conf.setAppName("my-spark-01")
conf.setMaster("local")
conf.set("spark.default.parallelism", "3")
SparkConf -> setAppName
def setAppName(name: String): SparkConf = {
set("spark.app.name", name)
}
SparkConf -> set 重载方法(两个参数)
def set(key: String, value: String): SparkConf = {
set(key, value, false)
}
SparkConf
private val settings = new ConcurrentHashMap[String, String]()
...
private[spark] def set(key: String, value: String, silent: Boolean): SparkConf = {
...
settings.put(key, value)
this
}
标签:set,String,value,源码,key,spark,SparkConf,Spark 来源: https://www.cnblogs.com/abc608088/p/16218935.html