How to replace RDD type of [String] with values of RDD type [String, Int]
<p>Sorry for the confusion in the initial question. Here is a questions with the reproducible example:</p>

<p>I have an rdd of <code>[String]</code> and I have a rdd of <code>[String, Long]</code>. I would like to have an rdd of <code>[Long]</code> based on the match of <code>String</code> of second with <code>String</code> of first. Example:</p>

<pre><code>//Create RDD
val textFile = sc.parallelize(Array("Spark can also be used for compute intensive tasks",
      "This code estimates pi by throwing darts at a circle"))
// tokenize, result: RDD[(String)]
val words = textFile.flatMap(line =&gt; line.split(" "))
// create index of distinct words, result:  RDD[(String,Long)]
val indexWords = words.distinct().zipWithIndex()
</code></pre>

<p>As a result, I would like to have an RDD with indexes of words instead of words in <code>"Spark can also be used for compute intensive tasks"</code>.</p>

<p>Sorry again and thanks</p>