我使用java的spark,并且我拥有500万行RDD。是否有一种溶剂可以让我计算RDD的行数。我试过RDD.count()
,但这需要很长时间。我已经看到,我可以使用功能fold
。但是我没有找到这个函数的java文档。 请你告诉我如何使用它或向我展示另一种解决方案来获取RDD的行数。计算RDD中的行数
这里是我的代码:
JavaPairRDD<String, String> lines = getAllCustomers(sc).cache();
JavaPairRDD<String,String> CFIDNotNull = lines.filter(notNull()).cache();
JavaPairRDD<String, Tuple2<String, String>> 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+"%");
谢谢。