Packages

class SparkContext extends Logging

Main entry point for Spark functionality. A SparkContext represents the connection to a Spark cluster, and can be used to create RDDs, accumulators and broadcast variables on that cluster.

Note

Only one SparkContext should be active per JVM. You must stop() the active SparkContext before creating a new one.

Linear Supertypes
Logging, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SparkContext
  2. Logging
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new SparkContext(master: String, appName: String, sparkHome: String = null, jars: Seq[String] = Nil, environment: Map[String, String] = Map())

    Alternative constructor that allows setting common Spark properties directly

    Alternative constructor that allows setting common Spark properties directly

    master

    Cluster URL to connect to (e.g. spark://host:port, local[4]).

    appName

    A name for your application, to display on the cluster web UI.

    sparkHome

    Location where Spark is installed on cluster nodes.

    jars

    Collection of JARs to send to the cluster. These can be paths on the local file system or HDFS, HTTP, HTTPS, or FTP URLs.

    environment

    Environment variables to set on worker nodes.

  2. new SparkContext(master: String, appName: String, conf: SparkConf)

    Alternative constructor that allows setting common Spark properties directly

    Alternative constructor that allows setting common Spark properties directly

    master

    Cluster URL to connect to (e.g. spark://host:port, local[4]).

    appName

    A name for your application, to display on the cluster web UI

    conf

    a org.apache.spark.SparkConf object specifying other Spark parameters

  3. new SparkContext()

    Create a SparkContext that loads settings from system properties (for instance, when launching with ./bin/spark-submit).

  4. new SparkContext(config: SparkConf)

    config

    a Spark Config object describing the application configuration. Any settings in this config overrides the default configs as well as system properties.

Type Members

  1. implicit class LogStringContext extends AnyRef
    Definition Classes
    Logging

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addArchive(path: String): Unit

    :: Experimental :: Add an archive to be downloaded and unpacked with this Spark job on every node.

    :: Experimental :: Add an archive to be downloaded and unpacked with this Spark job on every node.

    If an archive is added during execution, it will not be available until the next TaskSet starts.

    path

    can be either a local file, a file in HDFS (or other Hadoop-supported filesystems), or an HTTP, HTTPS or FTP URI. To access the file in Spark jobs, use SparkFiles.get(paths-to-files) to find its download/unpacked location. The given path should be one of .zip, .tar, .tar.gz, .tgz and .jar.

    Annotations
    @Experimental()
    Since

    3.1.0

    Note

    A path can be added only once. Subsequent additions of the same path are ignored.

  5. def addFile(path: String, recursive: Boolean): Unit

    Add a file to be downloaded with this Spark job on every node.

    Add a file to be downloaded with this Spark job on every node.

    If a file is added during execution, it will not be available until the next TaskSet starts.

    path

    can be either a local file, a file in HDFS (or other Hadoop-supported filesystems), or an HTTP, HTTPS or FTP URI. To access the file in Spark jobs, use SparkFiles.get(fileName) to find its download location.

    recursive

    if true, a directory can be given in path. Currently directories are only supported for Hadoop-supported filesystems.

    Note

    A path can be added only once. Subsequent additions of the same path are ignored.

  6. def addFile(path: String): Unit

    Add a file to be downloaded with this Spark job on every node.

    Add a file to be downloaded with this Spark job on every node.

    If a file is added during execution, it will not be available until the next TaskSet starts.

    path

    can be either a local file, a file in HDFS (or other Hadoop-supported filesystems), or an HTTP, HTTPS or FTP URI. To access the file in Spark jobs, use SparkFiles.get(fileName) to find its download location.

    Note

    A path can be added only once. Subsequent additions of the same path are ignored.

  7. def addJar(path: String): Unit

    Adds a JAR dependency for all tasks to be executed on this SparkContext in the future.

    Adds a JAR dependency for all tasks to be executed on this SparkContext in the future.

    If a jar is added during execution, it will not be available until the next TaskSet starts.

    path

    can be either a local file, a file in HDFS (or other Hadoop-supported filesystems), an HTTP, HTTPS or FTP URI, or local:/path for a file on every worker node.

    Note

    A path can be added only once. Subsequent additions of the same path are ignored.

  8. def addJobTag(tag: String): Unit

    Add a tag to be assigned to all the jobs started by this thread.

    Add a tag to be assigned to all the jobs started by this thread.

    Often, a unit of execution in an application consists of multiple Spark actions or jobs. Application programmers can use this method to group all those jobs together and give a group tag. The application can use org.apache.spark.sql.SparkSession.interruptTag to cancel all running executions with this tag. For example:

    // In the main thread:
    sc.addJobTag("myjobs")
    sc.parallelize(1 to 10000, 2).map { i => Thread.sleep(10); i }.count()
    
    // In a separate thread:
    spark.cancelJobsWithTag("myjobs")

    There may be multiple tags present at the same time, so different parts of application may use different tags to perform cancellation at different levels of granularity.

    tag

    The tag to be added. Cannot contain ',' (comma) character.

    Since

    3.5.0

  9. def addJobTags(tags: Set[String]): Unit

    Add multiple tags to be assigned to all the jobs started by this thread.

    Add multiple tags to be assigned to all the jobs started by this thread. See addJobTag for more details.

    tags

    The tags to be added. Cannot contain ',' (comma) character.

    Since

    4.0.0

  10. def addSparkListener(listener: SparkListenerInterface): Unit

    :: DeveloperApi :: Register a listener to receive up-calls from events that happen during execution.

    :: DeveloperApi :: Register a listener to receive up-calls from events that happen during execution.

    Annotations
    @DeveloperApi()
  11. def appName: String
  12. def applicationAttemptId: Option[String]
  13. def applicationId: String

    A unique identifier for the Spark application.

    A unique identifier for the Spark application. Its format depends on the scheduler implementation. (i.e. in case of local spark app something like 'local-1433865536131' in case of YARN something like 'application_1433865536131_34483' )

  14. def archives: Seq[String]
  15. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  16. def binaryFiles(path: String, minPartitions: Int = defaultMinPartitions): RDD[(String, PortableDataStream)]

    Get an RDD for a Hadoop-readable dataset as PortableDataStream for each file (useful for binary data)

    Get an RDD for a Hadoop-readable dataset as PortableDataStream for each file (useful for binary data)

    For example, if you have the following files:

    hdfs://a-hdfs-path/part-00000
    hdfs://a-hdfs-path/part-00001
    ...
    hdfs://a-hdfs-path/part-nnnnn

    Do val rdd = sparkContext.binaryFiles("hdfs://a-hdfs-path"),

    then rdd contains

    (a-hdfs-path/part-00000, its content)
    (a-hdfs-path/part-00001, its content)
    ...
    (a-hdfs-path/part-nnnnn, its content)
    path

    Directory to the input data files, the path can be comma separated paths as the list of inputs.

    minPartitions

    A suggestion value of the minimal splitting number for input data.

    returns

    RDD representing tuples of file path and corresponding file content

    Note

    Small files are preferred; very large files may cause bad performance.

    ,

    On some filesystems, .../path/* can be a more efficient way to read all files in a directory rather than .../path/ or .../path

    ,

    Partitioning is determined by data locality. This may result in too few partitions by default.

  17. def binaryRecords(path: String, recordLength: Int, conf: Configuration = hadoopConfiguration): RDD[Array[Byte]]

    Load data from a flat binary file, assuming the length of each record is constant.

    Load data from a flat binary file, assuming the length of each record is constant.

    path

    Directory to the input data files, the path can be comma separated paths as the list of inputs.

    recordLength

    The length at which to split the records

    conf

    Configuration for setting up the dataset.

    returns

    An RDD of data with values, represented as byte arrays

    Note

    We ensure that the byte array for each record in the resulting RDD has the provided record length.

  18. def broadcast[T](value: T)(implicit arg0: ClassTag[T]): Broadcast[T]

    Broadcast a read-only variable to the cluster, returning a org.apache.spark.broadcast.Broadcast object for reading it in distributed functions.

    Broadcast a read-only variable to the cluster, returning a org.apache.spark.broadcast.Broadcast object for reading it in distributed functions. The variable will be sent to each executor only once.

    value

    value to broadcast to the Spark nodes

    returns

    Broadcast object, a read-only variable cached on each machine

  19. def cancelAllJobs(): Unit

    Cancel all jobs that have been scheduled or are running.

  20. def cancelJob(jobId: Int): Unit

    Cancel a given job if it's scheduled or running.

    Cancel a given job if it's scheduled or running.

    jobId

    the job ID to cancel

    Note

    Throws InterruptedException if the cancel message cannot be sent

  21. def cancelJob(jobId: Int, reason: String): Unit

    Cancel a given job if it's scheduled or running.

    Cancel a given job if it's scheduled or running.

    jobId

    the job ID to cancel

    reason

    reason for cancellation

    Note

    Throws InterruptedException if the cancel message cannot be sent

  22. def cancelJobGroup(groupId: String): Unit

    Cancel active jobs for the specified group.

    Cancel active jobs for the specified group. See org.apache.spark.SparkContext.setJobGroup for more information.

    groupId

    the group ID to cancel

  23. def cancelJobGroup(groupId: String, reason: String): Unit

    Cancel active jobs for the specified group.

    Cancel active jobs for the specified group. See org.apache.spark.SparkContext.setJobGroup for more information.

    groupId

    the group ID to cancel

    reason

    reason for cancellation

    Since

    4.0.0

  24. def cancelJobGroupAndFutureJobs(groupId: String): Unit

    Cancel active jobs for the specified group, as well as the future jobs in this job group.

    Cancel active jobs for the specified group, as well as the future jobs in this job group. Note: the maximum number of job groups that can be tracked is set by 'spark.scheduler.numCancelledJobGroupsToTrack'. Once the limit is reached and a new job group is to be added, the oldest job group tracked will be discarded.

    groupId

    the group ID to cancel

  25. def cancelJobGroupAndFutureJobs(groupId: String, reason: String): Unit

    Cancel active jobs for the specified group, as well as the future jobs in this job group.

    Cancel active jobs for the specified group, as well as the future jobs in this job group. Note: the maximum number of job groups that can be tracked is set by 'spark.scheduler.numCancelledJobGroupsToTrack'. Once the limit is reached and a new job group is to be added, the oldest job group tracked will be discarded.

    groupId

    the group ID to cancel

    reason

    reason for cancellation

    Since

    4.0.0

  26. def cancelJobsWithTag(tag: String): Unit

    Cancel active jobs that have the specified tag.

    Cancel active jobs that have the specified tag. See org.apache.spark.SparkContext.addJobTag.

    tag

    The tag to be cancelled. Cannot contain ',' (comma) character.

    Since

    3.5.0

  27. def cancelJobsWithTag(tag: String, reason: String): Unit

    Cancel active jobs that have the specified tag.

    Cancel active jobs that have the specified tag. See org.apache.spark.SparkContext.addJobTag.

    tag

    The tag to be cancelled. Cannot contain ',' (comma) character.

    reason

    reason for cancellation

    Since

    4.0.0

  28. def cancelStage(stageId: Int): Unit

    Cancel a given stage and all jobs associated with it.

    Cancel a given stage and all jobs associated with it.

    stageId

    the stage ID to cancel

    Note

    Throws InterruptedException if the cancel message cannot be sent

  29. def cancelStage(stageId: Int, reason: String): Unit

    Cancel a given stage and all jobs associated with it.

    Cancel a given stage and all jobs associated with it.

    stageId

    the stage ID to cancel

    reason

    reason for cancellation

    Note

    Throws InterruptedException if the cancel message cannot be sent

  30. def checkpointFile[T](path: String)(implicit arg0: ClassTag[T]): RDD[T]
    Attributes
    protected[spark]
  31. def clearCallSite(): Unit

    Clear the thread-local property for overriding the call sites of actions and RDDs.

  32. def clearJobGroup(): Unit

    Clear the current thread's job group ID and its description.

  33. def clearJobTags(): Unit

    Clear the current thread's job tags.

    Clear the current thread's job tags.

    Since

    3.5.0

  34. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  35. def collectionAccumulator[T](name: String): CollectionAccumulator[T]

    Create and register a CollectionAccumulator, which starts with empty list and accumulates inputs by adding them into the list.

  36. def collectionAccumulator[T]: CollectionAccumulator[T]

    Create and register a CollectionAccumulator, which starts with empty list and accumulates inputs by adding them into the list.

  37. def defaultMinPartitions: Int

    Default min number of partitions for Hadoop RDDs when not given by user Notice that we use math.min so the "defaultMinPartitions" cannot be higher than 2.

    Default min number of partitions for Hadoop RDDs when not given by user Notice that we use math.min so the "defaultMinPartitions" cannot be higher than 2. The reasons for this are discussed in https://github.com/mesos/spark/pull/718

  38. def defaultParallelism: Int

    Default level of parallelism to use when not given by user (e.g.

    Default level of parallelism to use when not given by user (e.g. parallelize and makeRDD).

  39. def deployMode: String
  40. def doubleAccumulator(name: String): DoubleAccumulator

    Create and register a double accumulator, which starts with 0 and accumulates inputs by add.

  41. def doubleAccumulator: DoubleAccumulator

    Create and register a double accumulator, which starts with 0 and accumulates inputs by add.

  42. def emptyRDD[T](implicit arg0: ClassTag[T]): RDD[T]

    Get an RDD that has no partitions or elements.

  43. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  45. def files: Seq[String]
  46. def getAllPools: Seq[Schedulable]

    :: DeveloperApi :: Return pools for fair scheduler

    :: DeveloperApi :: Return pools for fair scheduler

    Annotations
    @DeveloperApi()
  47. def getCheckpointDir: Option[String]
  48. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  49. def getConf: SparkConf

    Return a copy of this SparkContext's configuration.

    Return a copy of this SparkContext's configuration. The configuration cannot be changed at runtime.

  50. def getExecutorMemoryStatus: Map[String, (Long, Long)]

    Return a map from the block manager to the max memory available for caching and the remaining memory available for caching.

  51. def getJobTags(): Set[String]

    Get the tags that are currently set to be assigned to all the jobs started by this thread.

    Get the tags that are currently set to be assigned to all the jobs started by this thread.

    Since

    3.5.0

  52. def getLocalProperty(key: String): String

    Get a local property set in this thread, or null if it is missing.

    Get a local property set in this thread, or null if it is missing. See org.apache.spark.SparkContext.setLocalProperty.

  53. def getPersistentRDDs: Map[Int, RDD[_]]

    Returns an immutable map of RDDs that have marked themselves as persistent via cache() call.

    Returns an immutable map of RDDs that have marked themselves as persistent via cache() call.

    Note

    This does not necessarily mean the caching or computation was successful.

  54. def getPoolForName(pool: String): Option[Schedulable]

    :: DeveloperApi :: Return the pool associated with the given name, if one exists

    :: DeveloperApi :: Return the pool associated with the given name, if one exists

    Annotations
    @DeveloperApi()
  55. def getRDDStorageInfo: Array[RDDInfo]

    :: DeveloperApi :: Return information about what RDDs are cached, if they are in mem or on disk, how much space they take, etc.

    :: DeveloperApi :: Return information about what RDDs are cached, if they are in mem or on disk, how much space they take, etc.

    Annotations
    @DeveloperApi()
  56. def getReadOnlyConf: ReadOnlySparkConf

    Get a read-only reference to the spark conf.

    Get a read-only reference to the spark conf. This is preferred version over getConf.

  57. def getSchedulingMode: SchedulingMode

    Return current scheduling mode

  58. def hadoopConfiguration: Configuration

    A default Hadoop Configuration for the Hadoop code (e.g.

    A default Hadoop Configuration for the Hadoop code (e.g. file systems) that we reuse.

    Note

    As it will be reused in all Hadoop RDDs, it's better not to modify it unless you plan to set some global configurations for all Hadoop RDDs.

  59. def hadoopFile[K, V, F <: InputFormat[K, V]](path: String)(implicit km: ClassTag[K], vm: ClassTag[V], fm: ClassTag[F]): RDD[(K, V)]

    Smarter version of hadoopFile() that uses class tags to figure out the classes of keys, values and the InputFormat so that users don't need to pass them directly.

    Smarter version of hadoopFile() that uses class tags to figure out the classes of keys, values and the InputFormat so that users don't need to pass them directly. Instead, callers can just write, for example,

    val file = sparkContext.hadoopFile[LongWritable, Text, TextInputFormat](path)
    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  60. def hadoopFile[K, V, F <: InputFormat[K, V]](path: String, minPartitions: Int)(implicit km: ClassTag[K], vm: ClassTag[V], fm: ClassTag[F]): RDD[(K, V)]

    Smarter version of hadoopFile() that uses class tags to figure out the classes of keys, values and the InputFormat so that users don't need to pass them directly.

    Smarter version of hadoopFile() that uses class tags to figure out the classes of keys, values and the InputFormat so that users don't need to pass them directly. Instead, callers can just write, for example,

    val file = sparkContext.hadoopFile[LongWritable, Text, TextInputFormat](path, minPartitions)
    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  61. def hadoopFile[K, V](path: String, inputFormatClass: Class[_ <: InputFormat[K, V]], keyClass: Class[K], valueClass: Class[V], minPartitions: Int = defaultMinPartitions): RDD[(K, V)]

    Get an RDD for a Hadoop file with an arbitrary InputFormat

    Get an RDD for a Hadoop file with an arbitrary InputFormat

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    inputFormatClass

    storage format of the data to be read

    keyClass

    Class of the key associated with the inputFormatClass parameter

    valueClass

    Class of the value associated with the inputFormatClass parameter

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  62. def hadoopRDD[K, V](conf: JobConf, inputFormatClass: Class[_ <: InputFormat[K, V]], keyClass: Class[K], valueClass: Class[V], minPartitions: Int = defaultMinPartitions): RDD[(K, V)]

    Get an RDD for a Hadoop-readable dataset from a Hadoop JobConf given its InputFormat and other necessary info (e.g.

    Get an RDD for a Hadoop-readable dataset from a Hadoop JobConf given its InputFormat and other necessary info (e.g. file name for a filesystem-based dataset, table name for HyperTable), using the older MapReduce API (org.apache.hadoop.mapred).

    conf

    JobConf for setting up the dataset. Note: This will be put into a Broadcast. Therefore if you plan to reuse this conf to create multiple RDDs, you need to make sure you won't modify the conf. A safe approach is always creating a new conf for a new RDD.

    inputFormatClass

    storage format of the data to be read

    keyClass

    Class of the key associated with the inputFormatClass parameter

    valueClass

    Class of the value associated with the inputFormatClass parameter

    minPartitions

    Minimum number of Hadoop Splits to generate.

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  63. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  64. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  65. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  66. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  67. def isLocal: Boolean
  68. def isStopped: Boolean

    returns

    true if context is stopped or in the midst of stopping.

  69. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  70. def jars: Seq[String]
  71. def killExecutor(executorId: String): Boolean

    :: DeveloperApi :: Request that the cluster manager kill the specified executor.

    :: DeveloperApi :: Request that the cluster manager kill the specified executor.

    returns

    whether the request is received.

    Annotations
    @DeveloperApi()
    Note

    This is an indication to the cluster manager that the application wishes to adjust its resource usage downwards. If the application wishes to replace the executor it kills through this method with a new one, it should follow up explicitly with a call to {{SparkContext#requestExecutors}}.

  72. def killExecutors(executorIds: Seq[String]): Boolean

    :: DeveloperApi :: Request that the cluster manager kill the specified executors.

    :: DeveloperApi :: Request that the cluster manager kill the specified executors.

    This is not supported when dynamic allocation is turned on.

    returns

    whether the request is received.

    Annotations
    @DeveloperApi()
    Note

    This is an indication to the cluster manager that the application wishes to adjust its resource usage downwards. If the application wishes to replace the executors it kills through this method with new ones, it should follow up explicitly with a call to {{SparkContext#requestExecutors}}.

  73. def killTaskAttempt(taskId: Long, interruptThread: Boolean = true, reason: String = "killed via SparkContext.killTaskAttempt"): Boolean

    Kill and reschedule the given task attempt.

    Kill and reschedule the given task attempt. Task ids can be obtained from the Spark UI or through SparkListener.onTaskStart.

    taskId

    the task ID to kill. This id uniquely identifies the task attempt.

    interruptThread

    whether to interrupt the thread running the task.

    reason

    the reason for killing the task, which should be a short string. If a task is killed multiple times with different reasons, only one reason will be reported.

    returns

    Whether the task was successfully killed.

  74. def listArchives(): Seq[String]

    :: Experimental :: Returns a list of archive paths that are added to resources.

    :: Experimental :: Returns a list of archive paths that are added to resources.

    Annotations
    @Experimental()
    Since

    3.1.0

  75. def listFiles(): Seq[String]

    Returns a list of file paths that are added to resources.

  76. def listJars(): Seq[String]

    Returns a list of jar files that are added to resources.

  77. val localProperties: InheritableThreadLocal[Properties]
    Attributes
    protected[spark]
  78. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  79. def logDebug(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  80. def logDebug(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  81. def logDebug(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  82. def logDebug(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  83. def logError(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  84. def logError(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  85. def logError(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  86. def logError(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  87. def logInfo(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  88. def logInfo(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  89. def logInfo(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  90. def logInfo(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  91. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  92. def logTrace(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  93. def logTrace(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  94. def logTrace(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  95. def logTrace(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  96. def logWarning(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  97. def logWarning(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  98. def logWarning(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  99. def logWarning(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  100. def longAccumulator(name: String): LongAccumulator

    Create and register a long accumulator, which starts with 0 and accumulates inputs by add.

  101. def longAccumulator: LongAccumulator

    Create and register a long accumulator, which starts with 0 and accumulates inputs by add.

  102. def makeRDD[T](seq: Seq[(T, Seq[String])])(implicit arg0: ClassTag[T]): RDD[T]

    Distribute a local Scala collection to form an RDD, with one or more location preferences (hostnames of Spark nodes) for each object.

    Distribute a local Scala collection to form an RDD, with one or more location preferences (hostnames of Spark nodes) for each object. Create a new partition for each collection item.

    seq

    list of tuples of data and location preferences (hostnames of Spark nodes)

    returns

    RDD representing data partitioned according to location preferences

  103. def makeRDD[T](seq: Seq[T], numSlices: Int = defaultParallelism)(implicit arg0: ClassTag[T]): RDD[T]

    Distribute a local Scala collection to form an RDD.

    Distribute a local Scala collection to form an RDD.

    This method is identical to parallelize.

    seq

    Scala collection to distribute

    numSlices

    number of partitions to divide the collection into

    returns

    RDD representing distributed collection

  104. def master: String
  105. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  106. def newAPIHadoopFile[K, V, F <: InputFormat[K, V]](path: String, fClass: Class[F], kClass: Class[K], vClass: Class[V], conf: Configuration = hadoopConfiguration): RDD[(K, V)]

    Get an RDD for a given Hadoop file with an arbitrary new API InputFormat and extra configuration options to pass to the input format.

    Get an RDD for a given Hadoop file with an arbitrary new API InputFormat and extra configuration options to pass to the input format.

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    fClass

    storage format of the data to be read

    kClass

    Class of the key associated with the fClass parameter

    vClass

    Class of the value associated with the fClass parameter

    conf

    Hadoop configuration

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  107. def newAPIHadoopFile[K, V, F <: InputFormat[K, V]](path: String)(implicit km: ClassTag[K], vm: ClassTag[V], fm: ClassTag[F]): RDD[(K, V)]

    Smarter version of newApiHadoopFile that uses class tags to figure out the classes of keys, values and the org.apache.hadoop.mapreduce.InputFormat (new MapReduce API) so that user don't need to pass them directly.

    Smarter version of newApiHadoopFile that uses class tags to figure out the classes of keys, values and the org.apache.hadoop.mapreduce.InputFormat (new MapReduce API) so that user don't need to pass them directly. Instead, callers can just write, for example: val file = sparkContext.hadoopFile[LongWritable, Text, TextInputFormat](path)

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  108. def newAPIHadoopRDD[K, V, F <: InputFormat[K, V]](conf: Configuration = hadoopConfiguration, fClass: Class[F], kClass: Class[K], vClass: Class[V]): RDD[(K, V)]

    Get an RDD for a given Hadoop file with an arbitrary new API InputFormat and extra configuration options to pass to the input format.

    Get an RDD for a given Hadoop file with an arbitrary new API InputFormat and extra configuration options to pass to the input format.

    conf

    Configuration for setting up the dataset. Note: This will be put into a Broadcast. Therefore if you plan to reuse this conf to create multiple RDDs, you need to make sure you won't modify the conf. A safe approach is always creating a new conf for a new RDD.

    fClass

    storage format of the data to be read

    kClass

    Class of the key associated with the fClass parameter

    vClass

    Class of the value associated with the fClass parameter

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  109. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  110. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  111. def objectFile[T](path: String, minPartitions: Int = defaultMinPartitions)(implicit arg0: ClassTag[T]): RDD[T]

    Load an RDD saved as a SequenceFile containing serialized objects, with NullWritable keys and BytesWritable values that contain a serialized partition.

    Load an RDD saved as a SequenceFile containing serialized objects, with NullWritable keys and BytesWritable values that contain a serialized partition. This is still an experimental storage format and may not be supported exactly as is in future Spark releases. It will also be pretty slow if you use the default serializer (Java serialization), though the nice thing about it is that there's very little effort required to save arbitrary objects.

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD representing deserialized data from the file(s)

  112. def parallelize[T](seq: Seq[T], numSlices: Int = defaultParallelism)(implicit arg0: ClassTag[T]): RDD[T]

    Distribute a local Scala collection to form an RDD.

    Distribute a local Scala collection to form an RDD.

    seq

    Scala collection to distribute

    numSlices

    number of partitions to divide the collection into

    returns

    RDD representing distributed collection

    Note

    Parallelize acts lazily. If seq is a mutable collection and is altered after the call to parallelize and before the first action on the RDD, the resultant RDD will reflect the modified collection. Pass a copy of the argument to avoid this.

    ,

    avoid using parallelize(Seq()) to create an empty RDD. Consider emptyRDD for an RDD with no partitions, or parallelize(Seq[T]()) for an RDD of T with empty partitions.

  113. def range(start: Long, end: Long, step: Long = 1, numSlices: Int = defaultParallelism): RDD[Long]

    Creates a new RDD[Long] containing elements from start to end(exclusive), increased by step every element.

    Creates a new RDD[Long] containing elements from start to end(exclusive), increased by step every element.

    start

    the start value.

    end

    the end value.

    step

    the incremental step

    numSlices

    number of partitions to divide the collection into

    returns

    RDD representing distributed range

    Note

    if we need to cache this RDD, we should make sure each partition does not exceed limit.

  114. def register(acc: AccumulatorV2[_, _], name: String): Unit

    Register the given accumulator with given name.

    Register the given accumulator with given name.

    Note

    Accumulators must be registered before use, or it will throw exception.

  115. def register(acc: AccumulatorV2[_, _]): Unit

    Register the given accumulator.

    Register the given accumulator.

    Note

    Accumulators must be registered before use, or it will throw exception.

  116. def removeJobTag(tag: String): Unit

    Remove a tag previously added to be assigned to all the jobs started by this thread.

    Remove a tag previously added to be assigned to all the jobs started by this thread. Noop if such a tag was not added earlier.

    tag

    The tag to be removed. Cannot contain ',' (comma) character.

    Since

    3.5.0

  117. def removeJobTags(tags: Set[String]): Unit

    Remove multiple tags to be assigned to all the jobs started by this thread.

    Remove multiple tags to be assigned to all the jobs started by this thread. See removeJobTag for more details.

    tags

    The tags to be removed. Cannot contain ',' (comma) character.

    Since

    4.0.0

  118. def removeSparkListener(listener: SparkListenerInterface): Unit

    :: DeveloperApi :: Deregister the listener from Spark's listener bus.

    :: DeveloperApi :: Deregister the listener from Spark's listener bus.

    Annotations
    @DeveloperApi()
  119. def requestExecutors(numAdditionalExecutors: Int): Boolean

    :: DeveloperApi :: Request an additional number of executors from the cluster manager.

    :: DeveloperApi :: Request an additional number of executors from the cluster manager.

    returns

    whether the request is received.

    Annotations
    @DeveloperApi()
  120. def requestTotalExecutors(numExecutors: Int, localityAwareTasks: Int, hostToLocalTaskCount: Map[String, Int]): Boolean

    Update the cluster manager on our scheduling needs.

    Update the cluster manager on our scheduling needs. Three bits of information are included to help it make decisions. This applies to the default ResourceProfile.

    numExecutors

    The total number of executors we'd like to have. The cluster manager shouldn't kill any running executor to reach this number, but, if all existing executors were to die, this is the number of executors we'd want to be allocated.

    localityAwareTasks

    The number of tasks in all active stages that have a locality preferences. This includes running, pending, and completed tasks.

    hostToLocalTaskCount

    A map of hosts to the number of tasks from all active stages that would like to like to run on that host. This includes running, pending, and completed tasks.

    returns

    whether the request is acknowledged by the cluster manager.

    Annotations
    @DeveloperApi()
  121. def resources: Map[String, ResourceInformation]
  122. def runApproximateJob[T, U, R](rdd: RDD[T], func: (TaskContext, Iterator[T]) => U, evaluator: ApproximateEvaluator[U, R], timeout: Long): PartialResult[R]

    :: DeveloperApi :: Run a job that can return approximate results.

    :: DeveloperApi :: Run a job that can return approximate results.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    evaluator

    ApproximateEvaluator to receive the partial results

    timeout

    maximum time to wait for the job, in milliseconds

    returns

    partial result (how partial depends on whether the job was finished before or after timeout)

    Annotations
    @DeveloperApi()
  123. def runJob[T, U](rdd: RDD[T], processPartition: (Iterator[T]) => U, resultHandler: (Int, U) => Unit)(implicit arg0: ClassTag[U]): Unit

    Run a job on all partitions in an RDD and pass the results to a handler function.

    Run a job on all partitions in an RDD and pass the results to a handler function.

    rdd

    target RDD to run tasks on

    processPartition

    a function to run on each partition of the RDD

    resultHandler

    callback to pass each result to

  124. def runJob[T, U](rdd: RDD[T], processPartition: (TaskContext, Iterator[T]) => U, resultHandler: (Int, U) => Unit)(implicit arg0: ClassTag[U]): Unit

    Run a job on all partitions in an RDD and pass the results to a handler function.

    Run a job on all partitions in an RDD and pass the results to a handler function. The function that is run against each partition additionally takes TaskContext argument.

    rdd

    target RDD to run tasks on

    processPartition

    a function to run on each partition of the RDD

    resultHandler

    callback to pass each result to

  125. def runJob[T, U](rdd: RDD[T], func: (Iterator[T]) => U)(implicit arg0: ClassTag[U]): Array[U]

    Run a job on all partitions in an RDD and return the results in an array.

    Run a job on all partitions in an RDD and return the results in an array.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    returns

    in-memory collection with a result of the job (each collection element will contain a result from one partition)

  126. def runJob[T, U](rdd: RDD[T], func: (TaskContext, Iterator[T]) => U)(implicit arg0: ClassTag[U]): Array[U]

    Run a job on all partitions in an RDD and return the results in an array.

    Run a job on all partitions in an RDD and return the results in an array. The function that is run against each partition additionally takes TaskContext argument.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    returns

    in-memory collection with a result of the job (each collection element will contain a result from one partition)

  127. def runJob[T, U](rdd: RDD[T], func: (Iterator[T]) => U, partitions: Seq[Int])(implicit arg0: ClassTag[U]): Array[U]

    Run a function on a given set of partitions in an RDD and return the results as an array.

    Run a function on a given set of partitions in an RDD and return the results as an array.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    partitions

    set of partitions to run on; some jobs may not want to compute on all partitions of the target RDD, e.g. for operations like first()

    returns

    in-memory collection with a result of the job (each collection element will contain a result from one partition)

  128. def runJob[T, U](rdd: RDD[T], func: (TaskContext, Iterator[T]) => U, partitions: Seq[Int])(implicit arg0: ClassTag[U]): Array[U]

    Run a function on a given set of partitions in an RDD and return the results as an array.

    Run a function on a given set of partitions in an RDD and return the results as an array. The function that is run against each partition additionally takes TaskContext argument.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    partitions

    set of partitions to run on; some jobs may not want to compute on all partitions of the target RDD, e.g. for operations like first()

    returns

    in-memory collection with a result of the job (each collection element will contain a result from one partition)

  129. def runJob[T, U](rdd: RDD[T], func: (TaskContext, Iterator[T]) => U, partitions: Seq[Int], resultHandler: (Int, U) => Unit)(implicit arg0: ClassTag[U]): Unit

    Run a function on a given set of partitions in an RDD and pass the results to the given handler function.

    Run a function on a given set of partitions in an RDD and pass the results to the given handler function. This is the main entry point for all actions in Spark.

    rdd

    target RDD to run tasks on

    func

    a function to run on each partition of the RDD

    partitions

    set of partitions to run on; some jobs may not want to compute on all partitions of the target RDD, e.g. for operations like first()

    resultHandler

    callback to pass each result to

  130. def sequenceFile[K, V](path: String, minPartitions: Int = defaultMinPartitions)(implicit km: ClassTag[K], vm: ClassTag[V], kcf: () => WritableConverter[K], vcf: () => WritableConverter[V]): RDD[(K, V)]

    Version of sequenceFile() for types implicitly convertible to Writables through a WritableConverter.

    Version of sequenceFile() for types implicitly convertible to Writables through a WritableConverter. For example, to access a SequenceFile where the keys are Text and the values are IntWritable, you could simply write

    sparkContext.sequenceFile[String, Int](path, ...)

    WritableConverters are provided in a somewhat strange way (by an implicit function) to support both subclasses of Writable and types for which we define a converter (e.g. Int to IntWritable). The most natural thing would've been to have implicit objects for the converters, but then we couldn't have an object for every subclass of Writable (you can't have a parameterized singleton object). We use functions instead to create a new converter for the appropriate type. In addition, we pass the converter a ClassTag of its type to allow it to figure out the Writable class to use in the subclass case.

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  131. def sequenceFile[K, V](path: String, keyClass: Class[K], valueClass: Class[V]): RDD[(K, V)]

    Get an RDD for a Hadoop SequenceFile with given key and value types.

    Get an RDD for a Hadoop SequenceFile with given key and value types.

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    keyClass

    Class of the key associated with SequenceFileInputFormat

    valueClass

    Class of the value associated with SequenceFileInputFormat

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  132. def sequenceFile[K, V](path: String, keyClass: Class[K], valueClass: Class[V], minPartitions: Int): RDD[(K, V)]

    Get an RDD for a Hadoop SequenceFile with given key and value types.

    Get an RDD for a Hadoop SequenceFile with given key and value types.

    path

    directory to the input data files, the path can be comma separated paths as a list of inputs

    keyClass

    Class of the key associated with SequenceFileInputFormat

    valueClass

    Class of the value associated with SequenceFileInputFormat

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD of tuples of key and corresponding value

    Note

    Because Hadoop's RecordReader class re-uses the same Writable object for each record, directly caching the returned RDD or directly passing it to an aggregation or shuffle operation will create many references to the same object. If you plan to directly cache, sort, or aggregate Hadoop writable objects, you should first copy them using a map function.

  133. def setCallSite(shortCallSite: String): Unit

    Set the thread-local property for overriding the call sites of actions and RDDs.

  134. def setCheckpointDir(directory: String): Unit

    Set the directory under which RDDs are going to be checkpointed.

    Set the directory under which RDDs are going to be checkpointed.

    directory

    path to the directory where checkpoint files will be stored (must be HDFS path if running in cluster)

  135. def setInterruptOnCancel(interruptOnCancel: Boolean): Unit

    Set the behavior of job cancellation from jobs started in this thread.

    Set the behavior of job cancellation from jobs started in this thread.

    interruptOnCancel

    If true, then job cancellation will result in Thread.interrupt() being called on the job's executor threads. This is useful to help ensure that the tasks are actually stopped in a timely manner, but is off by default due to HDFS-1208, where HDFS may respond to Thread.interrupt() by marking nodes as dead.

    Since

    3.5.0

  136. def setJobDescription(value: String): Unit

    Set a human readable description of the current job.

  137. def setJobGroup(groupId: String, description: String, interruptOnCancel: Boolean = false): Unit

    Assigns a group ID to all the jobs started by this thread until the group ID is set to a different value or cleared.

    Assigns a group ID to all the jobs started by this thread until the group ID is set to a different value or cleared.

    Often, a unit of execution in an application consists of multiple Spark actions or jobs. Application programmers can use this method to group all those jobs together and give a group description. Once set, the Spark web UI will associate such jobs with this group.

    The application can also use org.apache.spark.SparkContext.cancelJobGroup to cancel all running jobs in this group. For example,

    // In the main thread:
    sc.setJobGroup("some_job_to_cancel", "some job description")
    sc.parallelize(1 to 10000, 2).map { i => Thread.sleep(10); i }.count()
    
    // In a separate thread:
    sc.cancelJobGroup("some_job_to_cancel")
    interruptOnCancel

    If true, then job cancellation will result in Thread.interrupt() being called on the job's executor threads. This is useful to help ensure that the tasks are actually stopped in a timely manner, but is off by default due to HDFS-1208, where HDFS may respond to Thread.interrupt() by marking nodes as dead.

  138. def setLocalProperty(key: String, value: String): Unit

    Set a local property that affects jobs submitted from this thread, such as the Spark fair scheduler pool.

    Set a local property that affects jobs submitted from this thread, such as the Spark fair scheduler pool. User-defined properties may also be set here. These properties are propagated through to worker tasks and can be accessed there via org.apache.spark.TaskContext#getLocalProperty.

    These properties are inherited by child threads spawned from this thread. This may have unexpected consequences when working with thread pools. The standard java implementation of thread pools have worker threads spawn other worker threads. As a result, local properties may propagate unpredictably.

    To remove/unset property simply set value to null e.g. sc.setLocalProperty("key", null)

  139. def setLogLevel(logLevel: String): Unit

    Control our logLevel.

    Control our logLevel. This overrides any user-defined log settings.

    logLevel

    The desired log level as a string. Valid log levels include: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN

  140. val sparkUser: String
  141. val startTime: Long
  142. def statusTracker: SparkStatusTracker
  143. def stop(exitCode: Int): Unit

    Shut down the SparkContext with exit code that will passed to scheduler backend.

    Shut down the SparkContext with exit code that will passed to scheduler backend. In client mode, client side may call SparkContext.stop() to clean up but exit with code not equal to 0. This behavior cause resource scheduler such as ApplicationMaster exit with success status but client side exited with failed status. Spark can call this method to stop SparkContext and pass client side correct exit code to scheduler backend. Then scheduler backend should send the exit code to corresponding resource scheduler to keep consistent.

    exitCode

    Specified exit code that will passed to scheduler backend in client mode.

  144. def stop(): Unit

    Shut down the SparkContext.

  145. def submitJob[T, U, R](rdd: RDD[T], processPartition: (Iterator[T]) => U, partitions: Seq[Int], resultHandler: (Int, U) => Unit, resultFunc: => R): SimpleFutureAction[R]

    Submit a job for execution and return a FutureJob holding the result.

    Submit a job for execution and return a FutureJob holding the result.

    rdd

    target RDD to run tasks on

    processPartition

    a function to run on each partition of the RDD

    partitions

    set of partitions to run on; some jobs may not want to compute on all partitions of the target RDD, e.g. for operations like first()

    resultHandler

    callback to pass each result to

    resultFunc

    function to be executed when the result is ready

  146. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  147. def textFile(path: String, minPartitions: Int = defaultMinPartitions): RDD[String]

    Read a text file from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI, and return it as an RDD of Strings.

    Read a text file from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI, and return it as an RDD of Strings. The text files must be encoded as UTF-8.

    path

    path to the text file on a supported file system

    minPartitions

    suggested minimum number of partitions for the resulting RDD

    returns

    RDD of lines of the text file

  148. def toString(): String
    Definition Classes
    AnyRef → Any
  149. def uiWebUrl: Option[String]
  150. def union[T](first: RDD[T], rest: RDD[T]*)(implicit arg0: ClassTag[T]): RDD[T]

    Build the union of a list of RDDs passed as variable-length arguments.

  151. def union[T](rdds: Seq[RDD[T]])(implicit arg0: ClassTag[T]): RDD[T]

    Build the union of a list of RDDs.

  152. def version: String

    The version of Spark on which this application is running.

  153. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  154. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  155. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  156. def wholeTextFiles(path: String, minPartitions: Int = defaultMinPartitions): RDD[(String, String)]

    Read a directory of text files from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI.

    Read a directory of text files from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI. Each file is read as a single record and returned in a key-value pair, where the key is the path of each file, the value is the content of each file. The text files must be encoded as UTF-8.

    For example, if you have the following files:

    hdfs://a-hdfs-path/part-00000
    hdfs://a-hdfs-path/part-00001
    ...
    hdfs://a-hdfs-path/part-nnnnn

    Do val rdd = sparkContext.wholeTextFile("hdfs://a-hdfs-path"),

    then rdd contains

    (a-hdfs-path/part-00000, its content)
    (a-hdfs-path/part-00001, its content)
    ...
    (a-hdfs-path/part-nnnnn, its content)
    path

    Directory to the input data files, the path can be comma separated paths as the list of inputs.

    minPartitions

    A suggestion value of the minimal splitting number for input data.

    returns

    RDD representing tuples of file path and the corresponding file content

    Note

    Small files are preferred, large file is also allowable, but may cause bad performance.

    ,

    On some filesystems, .../path/* can be a more efficient way to read all files in a directory rather than .../path/ or .../path

    ,

    Partitioning is determined by data locality. This may result in too few partitions by default.

  157. def withLogContext(context: HashMap[String, String])(body: => Unit): Unit
    Attributes
    protected
    Definition Classes
    Logging

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Logging

Inherited from AnyRef

Inherited from Any

Ungrouped