title: How to group by RDD values Scala, Spark
body: <p>I have below scala program which reads a Couchbase bucket from a view and prints the results shown.</p>
  
  <pre><code>object CouchReader {
  
      def main(args: Array[String]) = {
          ...
          // Generate The Context
          val sc = new SparkContext(cfg)
  
          sc.couchbaseView(ViewQuery.from("Document", "activityView"))
          .map(_.key)
          .collect()
          .foreach(println)
      }
  }
  </code></pre>
  
  <p>This is the output</p>
  
  <pre><code>[35,4,-1]
  [35,4,-1]
  [35,4,10]
  [61,4,1]
  [61,4,10]
  </code></pre>
  
  <p>But, I need to get the output grouped by 1st and 2nd element and sum the 3rd element.</p>
  
  <p>i.e my desired output is </p>
  
  <pre><code>[35,4,8]
  [61,4,11]
  </code></pre>
  
  <p>How can I achieve that?</p>
  
  <p>I am still learning scala &amp; spark, spent some time on map, groupby but seems difficult to get it going.</p>