title: spark job get only one result for one key
body: <p>I now have a lot of key value pairs (key, value)</p>
  
  <p>Now for one key, I don't want to get the value's average or some other aggregations, I just need one value. (Get the distinct keys) </p>
  
  <p>Let me have an example here,</p>
  
  <pre><code>("1","apple")
  ("1","apple")
  ("2","orange")
  ("2","orange")
  ("1","apple")
  ("1","pear")
  </code></pre>
  
  <p>The result can be</p>
  
  <pre><code>("2","orange")
  ("1","apple")
  </code></pre>
  
  <p>or </p>
  
  <pre><code>("2","orange")
  ("1","pear")
  </code></pre>
  
  <p>I can use <code>reduceByKey(((a,b) =&gt; a))</code> to get this, but as there are a lot of keys, the time is very long. </p>
  
  <p>Any one have some better suggestions ?</p>
  
  <p>Thanks!</p>