title: reduceByKey: How does it work internally?
body: <p>I am new to Spark and Scala. I was confused about the way reduceByKey function works in Spark. Suppose we have the following code:</p>
  
  <pre><code>val lines = sc.textFile("data.txt")
  val pairs = lines.map(s =&gt; (s, 1))
  val counts = pairs.reduceByKey((a, b) =&gt; a + b)
  </code></pre>
  
  <p>The map function is clear: s is the key and it points to the line from <code>data.txt</code> and 1 is the value.</p>
  
  <p>However, I didn't get how the reduceByKey works internally? Does "a" points to the key? Alternatively, does "a" point to "s"? Then what does represent a + b? how are they filled?</p>