title: how to use spark intersection() by key or filter() with two RDD?
body: <p>I want to use <code>intersection()</code> by key or <code>filter()</code> in spark.</p>
  
  <p>But I really don't know how to use <code>intersection()</code> by key.</p>
  
  <p>So I tried to use <code>filter()</code>, but it's not worked.</p>
  
  <p>example - here is two RDD:</p>
  
  <pre><code>data1 //RDD[(String, Int)] = Array(("a", 1), ("a", 2), ("b", 2), ("b", 3), ("c", 1))
  data2 //RDD[(String, Int)] = Array(("a", 3), ("b", 5))
  
  val data3 = data2.map{_._1}
  
  data1.filter{_._1 == data3}.collect //Array[(String, Int] = Array()
  </code></pre>
  
  <p>I want to get a (key, value) pair with the same key as <code>data1</code> based on the key that <code>data2</code> has.</p>
  
  <p><code>Array(("a", 1), ("a", 2), ("b", 2), ("b", 3))</code> is the result I want.</p>
  
  <p>Is there a method to solve this problem using <code>intersection()</code> by key or <code>filter()</code>?</p>