Packages

c

org.apache.spark

SparkConf

class SparkConf extends ReadOnlySparkConf with Cloneable with Logging with Serializable

Configuration for a Spark application. Used to set various Spark parameters as key-value pairs.

Most of the time, you would create a SparkConf object with new SparkConf(), which will load values from any spark.* Java system properties set in your application as well. In this case, parameters you set directly on the SparkConf object take priority over system properties.

For unit tests, you can also call new SparkConf(false) to skip loading external settings and get the same configuration no matter what the system properties are.

All setter methods in this class support chaining. For example, you can write new SparkConf().setMaster("local").setAppName("My app").

Source
SparkConf.scala
Note

Once a SparkConf object is passed to Spark, it is cloned and can no longer be modified by the user. Spark does not support modifying the configuration at runtime.

Linear Supertypes
Serializable, Logging, Cloneable, ReadOnlySparkConf, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SparkConf
  2. Serializable
  3. Logging
  4. Cloneable
  5. ReadOnlySparkConf
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new SparkConf()

    Create a SparkConf that loads defaults from system properties and the classpath

  2. new SparkConf(loadDefaults: Boolean)

    loadDefaults

    whether to also load values from Java system properties

Type Members

  1. implicit class LogStringContext extends AnyRef
    Definition Classes
    Logging

Value Members

  1. def clone(): SparkConf

    Copy this object

    Copy this object

    Definition Classes
    SparkConf → AnyRef
  2. def contains(key: String): Boolean

    Does the configuration contain a given parameter?

    Does the configuration contain a given parameter?

    Definition Classes
    SparkConfReadOnlySparkConf
  3. def contains(entry: ConfigEntry[_]): Boolean

    Does the configuration have the typed config entry?

    Does the configuration have the typed config entry?

    Definition Classes
    ReadOnlySparkConf
  4. def get(key: String, defaultValue: String): String

    Get a parameter, falling back to a default if not set

    Get a parameter, falling back to a default if not set

    Definition Classes
    ReadOnlySparkConf
  5. def get(key: String): String

    Get a parameter; throws a NoSuchElementException if it's not set

    Get a parameter; throws a NoSuchElementException if it's not set

    Definition Classes
    ReadOnlySparkConf
  6. def getAll: Array[(String, String)]

    Get all parameters as a list of pairs

    Get all parameters as a list of pairs

    Definition Classes
    SparkConfReadOnlySparkConf
  7. def getAllWithPrefix(prefix: String): Array[(String, String)]

    Get all parameters that start with prefix

  8. def getAppId: String

    Returns the Spark application id, valid in the Driver after TaskScheduler registration and from the start in the Executor.

  9. def getAvroSchema: Map[Long, String]

    Gets all the avro schemas in the configuration used in the generic Avro record serializer

  10. def getBoolean(key: String, defaultValue: Boolean): Boolean

    Get a parameter as a boolean, falling back to a default if not set

    Get a parameter as a boolean, falling back to a default if not set

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    IllegalArgumentException If the value cannot be interpreted as a boolean

  11. def getDouble(key: String, defaultValue: Double): Double

    Get a parameter as a double, falling back to a default if not ste

    Get a parameter as a double, falling back to a default if not ste

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as a double

  12. def getExecutorEnv: Seq[(String, String)]

    Get all executor environment variables set on this SparkConf

  13. def getInt(key: String, defaultValue: Int): Int

    Get a parameter as an integer, falling back to a default if not set

    Get a parameter as an integer, falling back to a default if not set

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as an integer

  14. def getLong(key: String, defaultValue: Long): Long

    Get a parameter as a long, falling back to a default if not set

    Get a parameter as a long, falling back to a default if not set

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as a long

  15. def getOption(key: String): Option[String]

    Get a parameter as an Option

    Get a parameter as an Option

    Definition Classes
    SparkConfReadOnlySparkConf
  16. def getSizeAsBytes(key: String, defaultValue: Long): Long

    Get a size parameter as bytes, falling back to a default if not set.

    Get a size parameter as bytes, falling back to a default if not set.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as bytes

  17. def getSizeAsBytes(key: String, defaultValue: String): Long

    Get a size parameter as bytes, falling back to a default if not set.

    Get a size parameter as bytes, falling back to a default if not set. If no suffix is provided then bytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as bytes

  18. def getSizeAsBytes(key: String): Long

    Get a size parameter as bytes; throws a NoSuchElementException if it's not set.

    Get a size parameter as bytes; throws a NoSuchElementException if it's not set. If no suffix is provided then bytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as bytes

    java.util.NoSuchElementException If the size parameter is not set

  19. def getSizeAsGb(key: String, defaultValue: String): Long

    Get a size parameter as Gibibytes, falling back to a default if not set.

    Get a size parameter as Gibibytes, falling back to a default if not set. If no suffix is provided then Gibibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Gibibytes

  20. def getSizeAsGb(key: String): Long

    Get a size parameter as Gibibytes; throws a NoSuchElementException if it's not set.

    Get a size parameter as Gibibytes; throws a NoSuchElementException if it's not set. If no suffix is provided then Gibibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Gibibytes

    java.util.NoSuchElementException If the size parameter is not set

  21. def getSizeAsKb(key: String, defaultValue: String): Long

    Get a size parameter as Kibibytes, falling back to a default if not set.

    Get a size parameter as Kibibytes, falling back to a default if not set. If no suffix is provided then Kibibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Kibibytes

  22. def getSizeAsKb(key: String): Long

    Get a size parameter as Kibibytes; throws a NoSuchElementException if it's not set.

    Get a size parameter as Kibibytes; throws a NoSuchElementException if it's not set. If no suffix is provided then Kibibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Kibibytes

    java.util.NoSuchElementException If the size parameter is not set

  23. def getSizeAsMb(key: String, defaultValue: String): Long

    Get a size parameter as Mebibytes, falling back to a default if not set.

    Get a size parameter as Mebibytes, falling back to a default if not set. If no suffix is provided then Mebibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Mebibytes

  24. def getSizeAsMb(key: String): Long

    Get a size parameter as Mebibytes; throws a NoSuchElementException if it's not set.

    Get a size parameter as Mebibytes; throws a NoSuchElementException if it's not set. If no suffix is provided then Mebibytes are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as Mebibytes

    java.util.NoSuchElementException If the size parameter is not set

  25. def getTimeAsMs(key: String, defaultValue: String): Long

    Get a time parameter as milliseconds, falling back to a default if not set.

    Get a time parameter as milliseconds, falling back to a default if not set. If no suffix is provided then milliseconds are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as milliseconds

  26. def getTimeAsMs(key: String): Long

    Get a time parameter as milliseconds; throws a NoSuchElementException if it's not set.

    Get a time parameter as milliseconds; throws a NoSuchElementException if it's not set. If no suffix is provided then milliseconds are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as milliseconds

    java.util.NoSuchElementException If the time parameter is not set

  27. def getTimeAsSeconds(key: String, defaultValue: String): Long

    Get a time parameter as seconds, falling back to a default if not set.

    Get a time parameter as seconds, falling back to a default if not set. If no suffix is provided then seconds are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as seconds

  28. def getTimeAsSeconds(key: String): Long

    Get a time parameter as seconds; throws a NoSuchElementException if it's not set.

    Get a time parameter as seconds; throws a NoSuchElementException if it's not set. If no suffix is provided then seconds are assumed.

    Definition Classes
    ReadOnlySparkConf
    Exceptions thrown

    NumberFormatException If the value cannot be interpreted as seconds

    java.util.NoSuchElementException If the time parameter is not set

  29. def registerAvroSchemas(schemas: Schema*): SparkConf

    Use Kryo serialization and register the given set of Avro schemas so that the generic record serializer can decrease network IO

  30. def registerKryoClasses(classes: Array[Class[_]]): SparkConf

    Use Kryo serialization and register the given set of classes with Kryo.

    Use Kryo serialization and register the given set of classes with Kryo. If called multiple times, this will append the classes from all calls together.

  31. def remove(key: String): SparkConf

    Remove a parameter from the configuration

  32. def set(key: String, value: String): SparkConf

    Set a configuration variable.

  33. def setAll(settings: Iterable[(String, String)]): SparkConf

    Set multiple parameters together

  34. def setAppName(name: String): SparkConf

    Set a name for your application.

    Set a name for your application. Shown in the Spark web UI.

  35. def setExecutorEnv(variables: Array[(String, String)]): SparkConf

    Set multiple environment variables to be used when launching executors.

    Set multiple environment variables to be used when launching executors. (Java-friendly version.)

  36. def setExecutorEnv(variables: Seq[(String, String)]): SparkConf

    Set multiple environment variables to be used when launching executors.

    Set multiple environment variables to be used when launching executors. These variables are stored as properties of the form spark.executorEnv.VAR_NAME (for example spark.executorEnv.PATH) but this method makes them easier to set.

  37. def setExecutorEnv(variable: String, value: String): SparkConf

    Set an environment variable to be used when launching executors for this application.

    Set an environment variable to be used when launching executors for this application. These variables are stored as properties of the form spark.executorEnv.VAR_NAME (for example spark.executorEnv.PATH) but this method makes them easier to set.

  38. def setIfMissing(key: String, value: String): SparkConf

    Set a parameter if it isn't already configured

  39. def setJars(jars: Array[String]): SparkConf

    Set JAR files to distribute to the cluster.

    Set JAR files to distribute to the cluster. (Java-friendly version.)

  40. def setJars(jars: Seq[String]): SparkConf

    Set JAR files to distribute to the cluster.

  41. def setMaster(master: String): SparkConf

    The master URL to connect to, such as "local" to run locally with one thread, "local[4]" to run locally with 4 cores, or "spark://master:7077" to run on a Spark standalone cluster.

  42. def setSparkHome(home: String): SparkConf

    Set the location where Spark is installed on worker nodes.

  43. def toDebugString: String

    Return a string listing all keys and values, one per line.

    Return a string listing all keys and values, one per line. This is useful to print the configuration out for debugging.