Added an optimized count to VertexSetRDD.

This commit is contained in:
Reynold Xin 2013-11-30 14:24:18 -08:00
parent 689f757f7a
commit b30e0ae035
3 changed files with 7 additions and 2 deletions

View file

@ -139,8 +139,6 @@ object Pregel {
* @param initialMsg the message each vertex will receive at the on
* the first iteration.
*
* @param numIter the number of iterations to run this computation.
*
* @param vprog the user-defined vertex program which runs on each
* vertex and receives the inbound message and computes a new vertex
* value. On the first iteration the vertex program is invoked on

View file

@ -101,6 +101,11 @@ class VertexSetRDD[@specialized VD: ClassManifest](
/** Persist this RDD with the default storage level (`MEMORY_ONLY`). */
override def cache(): VertexSetRDD[VD] = persist()
/** Return the number of vertices in this set. */
override def count(): Long = {
partitionsRDD.map(_.size).reduce(_ + _)
}
/**
* Provide the `RDD[(Vid, VD)]` equivalent output.
*/

View file

@ -42,6 +42,8 @@ class VertexPartition[@specialized(Long, Int, Double) VD: ClassManifest](
val capacity: Int = index.capacity
def size: Int = mask.cardinality
/**
* Pass each vertex attribute along with the vertex id through a map
* function and retain the original RDD's partitioning and index.