title: How to generate unique id for each record spark
body: <p>I have a huge datasets with MM+ records and I am trying to assign unique id to each record. I tried below code but it takes lot of time as row id is sequential. I have tried tweak memory parameters to optimize job, couldn't gain much performance.</p>
  
  <p><strong>sample snippet:</strong></p>
  
  <pre><code>JavaRDD&lt;String&gt; rawRdd=......
  rawRdd.zipWithIndex()
  .mapToPair(t-&gt;new Tuple2&lt;Long,String&gt;(t._2,t._1))
  </code></pre>
  
  <p>Are there any better way to assign unique id? thanks</p>