title: Understanding reduceByKey function definition Spark Scala
body: <p>The <code>reduceByKey</code> function for a <code>Pair RDD</code> in spark has the following definition:</p>
  
  <pre><code>def reduceByKey(func: (V, V) =&gt; V): RDD[(K, V)]
  </code></pre>
  
  <p>I understand that <code>reduceByKey</code> takes the argument function applies it to the values of the keys. What I am trying to understand is how to read this definition where the function is taking 2 values as an input i.e. <code>(V, V) =&gt; V</code>. Shouldn't it be <code>V =&gt; V</code>, just like the <code>mapValues</code> function where the function is applied on the value V to yield U which is a value of same or different type:</p>
  
  <pre><code>def mapValues[U](f: (V) ⇒ U): RDD[(K, U)]
  </code></pre>
  
  <p>Is this because <code>reduceByKey</code> is applied to all the values (for the same key) at once, and <code>mapValues</code> is applied to each value (irrespective of the key) one at a time?, in which case shouldn't it be defined as something like <code>(V1, V2) =&gt; V</code></p>