Skip to content

Commit c55f52f

Browse files
committed
Tests that reproduce the problems from SPARK-1188.
1 parent d666053 commit c55f52f

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

graphx/src/test/scala/org/apache/spark/graphx/impl/EdgePartitionSuite.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class EdgePartitionSuite extends FunSuite {
3434
builder.add(e.srcId, e.dstId, e.attr)
3535
}
3636
val edgePartition = builder.toEdgePartition
37-
assert(edgePartition.reverse.iterator.map(_.copy()).toList === reversedEdges)
38-
assert(edgePartition.reverse.reverse.iterator.map(_.copy()).toList === edges)
37+
assert(edgePartition.reverse.iterator.toList === reversedEdges)
38+
assert(edgePartition.reverse.reverse.iterator.toList === edges)
3939
}
4040

4141
test("map") {
@@ -45,7 +45,7 @@ class EdgePartitionSuite extends FunSuite {
4545
builder.add(e.srcId, e.dstId, e.attr)
4646
}
4747
val edgePartition = builder.toEdgePartition
48-
assert(edgePartition.map(e => e.srcId + e.dstId).iterator.map(_.copy()).toList ===
48+
assert(edgePartition.map(e => e.srcId + e.dstId).iterator.toList ===
4949
edges.map(e => e.copy(attr = e.srcId + e.dstId)))
5050
}
5151

@@ -58,7 +58,7 @@ class EdgePartitionSuite extends FunSuite {
5858
builder.add(e.srcId, e.dstId, e.attr)
5959
}
6060
val edgePartition = builder.toEdgePartition
61-
assert(edgePartition.groupEdges(_ + _).iterator.map(_.copy()).toList === groupedEdges)
61+
assert(edgePartition.groupEdges(_ + _).iterator.toList === groupedEdges)
6262
}
6363

6464
test("indexIterator") {
@@ -72,8 +72,8 @@ class EdgePartitionSuite extends FunSuite {
7272

7373
val edgePartition = builder.toEdgePartition
7474
assert(edgePartition.iterator.map(_.copy()).toList === sortedEdges)
75-
assert(edgePartition.indexIterator(_ == 0).map(_.copy()).toList === edgesFrom0)
76-
assert(edgePartition.indexIterator(_ == 1).map(_.copy()).toList === edgesFrom1)
75+
assert(edgePartition.indexIterator(_ == 0).toList === edgesFrom0)
76+
assert(edgePartition.indexIterator(_ == 1).toList === edgesFrom1)
7777
}
7878

7979
test("innerJoin") {
@@ -87,7 +87,7 @@ class EdgePartitionSuite extends FunSuite {
8787
val a = makeEdgePartition(aList)
8888
val b = makeEdgePartition(bList)
8989

90-
assert(a.innerJoin(b) { (src, dst, a, b) => a }.iterator.map(_.copy()).toList ===
90+
assert(a.innerJoin(b) { (src, dst, a, b) => a }.iterator.toList ===
9191
List(Edge(0, 1, 0), Edge(1, 0, 0), Edge(5, 5, 0)))
9292
}
9393
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.graphx.impl
19+
20+
import scala.reflect.ClassTag
21+
import scala.util.Random
22+
23+
import org.scalatest.FunSuite
24+
25+
import org.apache.spark.graphx._
26+
27+
class EdgeTripletIteratorSuite extends FunSuite {
28+
test("iterator.toList") {
29+
val builder = new EdgePartitionBuilder[Int]
30+
builder.add(1, 2, 0)
31+
builder.add(1, 3, 0)
32+
builder.add(1, 4, 0)
33+
val vidmap = new VertexIdToIndexMap
34+
vidmap.add(1)
35+
vidmap.add(2)
36+
vidmap.add(3)
37+
vidmap.add(4)
38+
val vs = Array.fill(vidmap.capacity)(0)
39+
val iter = new EdgeTripletIterator[Int, Int](vidmap, vs, builder.toEdgePartition)
40+
val result = iter.toList.map(et => (et.srcId, et.dstId))
41+
assert(result === Seq((1, 2), (1, 3), (1, 4)))
42+
}
43+
}

0 commit comments

Comments
 (0)