diff options
author | Kenji Kikushima <kikushima.kenji@lab.ntt.co.jp> | 2015-01-21 12:34:00 -0800 |
---|---|---|
committer | Ankur Dave <ankurdave@gmail.com> | 2015-01-21 12:36:03 -0800 |
commit | 3ee3ab592eee831d759c940eb68231817ad6d083 (patch) | |
tree | 2fad4e0faa23eab5909b4316214b44b588e15699 /graphx/src/test | |
parent | 7450a992b3b543a373c34fc4444a528954ac4b4a (diff) | |
download | spark-3ee3ab592eee831d759c940eb68231817ad6d083.tar.gz spark-3ee3ab592eee831d759c940eb68231817ad6d083.tar.bz2 spark-3ee3ab592eee831d759c940eb68231817ad6d083.zip |
[SPARK-5064][GraphX] Add numEdges upperbound validation for R-MAT graph generator to prevent infinite loop
I looked into GraphGenerators#chooseCell, and found that chooseCell can't generate more edges than pow(2, (2 * (log2(numVertices)-1))) to make a Power-law graph. (Ex. numVertices:4 upperbound:4, numVertices:8 upperbound:16, numVertices:16 upperbound:64)
If we request more edges over the upperbound, rmatGraph fall into infinite loop. So, how about adding an argument validation?
Author: Kenji Kikushima <kikushima.kenji@lab.ntt.co.jp>
Closes #3950 from kj-ki/SPARK-5064 and squashes the following commits:
4ee18c7 [Ankur Dave] Reword error message and add unit test
d760bc7 [Kenji Kikushima] Add numEdges upperbound validation for R-MAT graph generator to prevent infinite loop.
Diffstat (limited to 'graphx/src/test')
-rw-r--r-- | graphx/src/test/scala/org/apache/spark/graphx/util/GraphGeneratorsSuite.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/graphx/src/test/scala/org/apache/spark/graphx/util/GraphGeneratorsSuite.scala b/graphx/src/test/scala/org/apache/spark/graphx/util/GraphGeneratorsSuite.scala index 3abefbe52f..8d9c8ddccb 100644 --- a/graphx/src/test/scala/org/apache/spark/graphx/util/GraphGeneratorsSuite.scala +++ b/graphx/src/test/scala/org/apache/spark/graphx/util/GraphGeneratorsSuite.scala @@ -110,4 +110,14 @@ class GraphGeneratorsSuite extends FunSuite with LocalSparkContext { } } + test("SPARK-5064 GraphGenerators.rmatGraph numEdges upper bound") { + withSpark { sc => + val g1 = GraphGenerators.rmatGraph(sc, 4, 4) + assert(g1.edges.count() === 4) + intercept[IllegalArgumentException] { + val g2 = GraphGenerators.rmatGraph(sc, 4, 8) + } + } + } + } |