title: Sum values of each unique key in Apache Spark RDD
body: <p>I have an <code>RDD[(String, (Long, Long))]</code> where each element is not unique:</p>
  
  <pre><code>(com.instagram.android,(2,0))
  (com.android.contacts,(6,1))
  (com.android.contacts,(3,4))
  (com.instagram.android,(8,3))
  ...
  </code></pre>
  
  <p>So I want to obtain an <code>RDD</code> where each element is the sum of the two values for every unique key:</p>
  
  <pre><code>(com.instagram.android,(10,3))
  (com.android.contacts,(9,5))
  ...
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>val appNamesAndPropertiesRdd = appNodesRdd.map({
    case Row(_, appName, totalUsageTime, usageFrequency, _, _, _, _) =&gt; 
      (appName, (totalUsageTime, usageFrequency))
  })
  </code></pre>