File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
graphx/src/test/scala/org/apache/spark/graphx Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,31 @@ class GraphSuite extends FunSuite with LocalSparkContext {
159159 }
160160 }
161161
162+ test(" mapVertices changing type with same erased type" ) {
163+ withSpark { sc =>
164+ val vertices = sc.parallelize(Array [(Long , Option [java.lang.Integer ])](
165+ (1L , Some (1 )),
166+ (2L , Some (2 )),
167+ (3L , Some (3 ))
168+ ))
169+ val edges = sc.parallelize(Array (
170+ Edge (1L , 2L , 0 ),
171+ Edge (2L , 3L , 0 ),
172+ Edge (3L , 1L , 0 )
173+ ))
174+ val graph0 = Graph (vertices, edges)
175+ // Trigger initial vertex replication
176+ graph0.triplets.foreach(x => {})
177+ // Change type of replicated vertices, but conserve erased type
178+ val graph1 = graph0.mapVertices {
179+ case (vid, integerOpt) => integerOpt.map((x : java.lang.Integer ) => (x.toDouble): java.lang.Double )
180+ }
181+ // Access replicated vertices, exposing the erased type
182+ val graph2 = graph1.mapTriplets(t => t.srcAttr.get)
183+ assert(graph2.edges.map(_.attr).collect.toSet === Set [java.lang.Double ](1.0 , 2.0 , 3.0 ))
184+ }
185+ }
186+
162187 test(" mapEdges" ) {
163188 withSpark { sc =>
164189 val n = 3
You can’t perform that action at this time.
0 commit comments