title: difference between rdd.collect().toMap to rdd.collectAsMap()?
body: <p>Is there any performance impact when I use collectAsMap on my RDD instead of rdd.collect().toMap ? </p>
  
  <p>I have a key value rdd and I want to convert to HashMap as far I know collect() is not efficient on large data sets as it runs on driver can I use collectAsMap instead is there any performance impact ? </p>
  
  <p>Original: </p>
  
  <pre class="lang-scala prettyprint-override"><code>val QuoteHashMap=QuoteRDD.collect().toMap 
  val QuoteRDDData=QuoteHashMap.values.toSeq 
  val QuoteRDDSet=sc.parallelize(QuoteRDDData.map(x =&gt; x.toString.replace("(","").replace(")",""))) 
  QuoteRDDSet.saveAsTextFile(Quotepath) 
  </code></pre>
  
  <p>Change:</p>
  
  <pre><code>val QuoteHashMap=QuoteRDD.collectAsMap() 
  val QuoteRDDData=QuoteHashMap.values.toSeq 
  val QuoteRDDSet=sc.parallelize(QuoteRDDData.map(x =&gt; x.toString.replace("(","").replace(")",""))) 
  QuoteRDDSet.saveAsTextFile(Quotepath)
  </code></pre>