Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/src/main/scala/org/apache/spark/SparkConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ trait ReadOnlySparkConf {
/** Get all parameters as a list of pairs */
def getAll: Array[(String, String)]

/** Get all parameters as a Java-friendly map */
def getAllAsJavaMap: JMap[String, String] = getAll.toMap.asJava

/**
* Get a parameter as an integer, falling back to a default if not set
*
Expand Down
12 changes: 12 additions & 0 deletions core/src/test/scala/org/apache/spark/SparkConfSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ class SparkConfSuite extends SparkFunSuite with LocalSparkContext with ResetSyst
assert(conf.getOption("k4") === None)
}

test("getAllAsJavaMap") {
val conf = new SparkConf(false)
assert(conf.getAllAsJavaMap.isEmpty)
conf.set("k1", "v1")
conf.setAll(Seq(("k2", "v2"), ("k3", "v3")))
val javaMap = conf.getAllAsJavaMap
assert(javaMap.size() === 3)
assert(javaMap.get("k1") === "v1")
assert(javaMap.get("k2") === "v2")
assert(javaMap.get("k3") === "v3")
}

test("basic getAllWithPrefix") {
val prefix = "spark.prefix."
val conf = new SparkConf(false)
Expand Down