Skip to content

Commit

Permalink
getAllConfs return an immutable Map instead of an Array.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Aug 6, 2014
1 parent 4b19d6c commit 3ac11ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.apache.spark.sql

import scala.collection.immutable
import scala.collection.JavaConversions._

import java.util.Properties

import scala.collection.JavaConverters._

private[spark] object SQLConf {
val COMPRESS_CACHED = "spark.sql.inMemoryColumnarStorage.compressed"
Expand Down Expand Up @@ -105,10 +107,8 @@ trait SQLConf {
/** ********************** SQLConf functionality methods ************ */

/** Set Spark SQL configuration properties. */
def setConf(props: Properties): Unit = {
settings.synchronized {
props.asScala.foreach { case (k, v) => settings.put(k, v) }
}
def setConf(props: Properties): Unit = settings.synchronized {
props.foreach { case (k, v) => settings.put(k, v) }
}

/** Set the given Spark SQL configuration property. */
Expand All @@ -131,8 +131,11 @@ trait SQLConf {
Option(settings.get(key)).getOrElse(defaultValue)
}

/** Return all the configuration properties that have been set (i.e. not the default). */
def getAllConfs: Array[(String, String)] = settings.synchronized { settings.asScala.toArray }
/**
* Return all the configuration properties that have been set (i.e. not the default).
* This creates a new copy of the config properties in the form of a Map.
*/
def getAllConfs: immutable.Map[String, String] = settings.synchronized { settings.toMap }

private[spark] def clear() {
settings.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ case class SetCommand(
case (None, None) =>
context.getAllConfs.map { case (k, v) =>
s"$k=$v"
}
}.toSeq

case _ =>
throw new IllegalArgumentException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SQLConfSuite extends QueryTest {

test("programmatic ways of basic setting and getting") {
clear()
assert(getAllConfs.toSet === Set())
assert(getAllConfs.size === 0)

setConf(testKey, testVal)
assert(getConf(testKey) == testVal)
Expand Down

0 comments on commit 3ac11ef

Please sign in to comment.