title: how to combine two JavaPairRDDs by left key and right values
body: <p>JavaPairRDD&lt; String, Long > one:</p>
  
  <blockquote>
    <p>[(A, 0), (B, 0), (C, 0), (D, 0), (E, 0)... ]</p>
  </blockquote>
  
  <p>JavaPairRDD&lt; String, Long > two:</p>
  
  <blockquote>
    <p>[(B, 1), (C, 5), (D, 21)]</p>
  </blockquote>
  
  <p>output should be:</p>
  
  <blockquote>
    <p>[(A, 0), (B, 1), (C, 5), (D, 21), (E, 0)... ]</p>
  </blockquote>
  
  <p>To use values of second rdd based on keys of first rdd, <em>aggregateByKey</em>, <em>union</em>, <em>join</em> (left or right) methods were tried, but didn't work. </p>
  
  <pre><code>JavaPairRDD&lt;String, Object&gt; currentRdd = firstRdd.fullOuterJoin(secondRdd).map(stringTuple2Tuple2 -&gt; new Tuple2&lt;String, Long&gt;(stringTuple2Tuple2._1(), stringTuple2Tuple2._2()._2().get()));
  </code></pre>
  
  <p>How can i combine two JavaPairRDD like this?</p>