title: Why the Spark stage only have one function. Instead of so Many transformation in a map stage
body: <p>I have confused that why a stage only have one function.
  In the Code below, the map stage should contain <strong>two map functions</strong> instead of one;</p>
  <pre><code>def main(args: Array[String]): Unit = {
      val conf = new SparkConf().setAppName(&quot;test&quot;).setMaster(&quot;local[2]&quot;)
      val sc = new SparkContext(conf)
      val data = Array(&quot;Runoob&quot;, &quot;Baidu&quot;, &quot;Google&quot;)
  
      val distData = sc.parallelize(data).map(x =&gt; (x, 1))
        .map(x =&gt; x._2 + 1)
        .collect()
      distData.length
    }
   
  </code></pre>
  <blockquote>
  <p>A stage is a set of independent tasks all computing the same function that need to run as part of a Spark job, where all the tasks have the same shuffle dependencies. Each DAG of tasks run by the scheduler is split up into stages at the boundaries where shuffle occurs, and then the DAGScheduler runs these stages in topological order.</p>
  </blockquote>
  <p>The Stage meaning in this url; <a href="https://spark.apache.org/docs/1.2.1/api/java/org/apache/spark/scheduler/Stage.html" rel="nofollow noreferrer">enter link description here</a></p>