Skip to content

Commit

Permalink
[TEST] VertexRDD.apply mergeFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
larryxiao committed Aug 25, 2014
1 parent 4fbc29c commit 6a35ea8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions graphx/src/test/scala/org/apache/spark/graphx/VertexRDDSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,21 @@ class VertexRDDSuite extends FunSuite with LocalSparkContext {
}
}

test("mergeFunc") {
// test to see if the mergeFunc is working correctly
withSpark { sc =>
// VertexRDD default constructor: Duplicate entries are removed arbitrarily.
// val verts = VertexRDD(sc.parallelize(List((0L, 1), (0L, 2), (1L, 3), (1L, 3), (1L, 3))))
// ensure constructor preserve duplicate vertex
// assert(verts.collect.toSet == Set((0L, 1), (0L, 2), (1L, 3), (1L, 3), (1L, 3)))
// won't pass

val verts = sc.parallelize(List((0L, 1), (0L, 2), (1L, 3), (1L, 3), (1L, 3)))
val edges = EdgeRDD.fromEdges(sc.parallelize(List.empty[Edge[Int]]))
val rdd = VertexRDD(verts, edges, 0, (a: Int, b: Int) => a + b)
// test merge function
assert(rdd.collect.toSet == Set((0L, 3), (1L, 9)))
}
}

}

0 comments on commit 6a35ea8

Please sign in to comment.