title: Count number of rows in an RDD
body: <p>I'm using spark with java, and i hava an RDD of 5 millions rows. Is there a sollution that allows me to calculate the number of rows of my RDD. I've tried <code>RDD.count()</code> but it takes a lot of time. I've seen that i can use the function <code>fold</code>. But i didn't found a java documentation of this function. 
  Could you please show me how to use it or show me another solution to get the number of rows of my RDD. </p>
  
  <p>Here is my code :</p>
  
  <pre><code>JavaPairRDD&lt;String, String&gt; lines = getAllCustomers(sc).cache();
  JavaPairRDD&lt;String,String&gt; CFIDNotNull = lines.filter(notNull()).cache();
  JavaPairRDD&lt;String, Tuple2&lt;String, String&gt;&gt; join =lines.join(CFIDNotNull).cache();
  
  double count_ctid = (double)join.count(); // i want to get the count of these three RDD
  double all = (double)lines.count();
  double count_cfid = all - CFIDNotNull.count();
  System.out.println("********** :"+count_cfid*100/all +"% and now : "+ count_ctid*100/all+"%");
  </code></pre>
  
  <p>Thank you.</p>