diff options
author | Zheng RuiFeng <ruifengz@foxmail.com> | 2016-11-14 19:42:00 +0000 |
---|---|---|
committer | DB Tsai <dbtsai@dbtsai.com> | 2016-11-14 19:42:00 +0000 |
commit | 75934457d75996be71ffd0d4b448497d656c0d40 (patch) | |
tree | f425d2cdf04d12996526c503c4c108a6eed22e29 /graphx/src | |
parent | 89d1fa58dbe88560b1f2b0362fcc3035ccc888be (diff) | |
download | spark-75934457d75996be71ffd0d4b448497d656c0d40.tar.gz spark-75934457d75996be71ffd0d4b448497d656c0d40.tar.bz2 spark-75934457d75996be71ffd0d4b448497d656c0d40.zip |
[SPARK-11496][GRAPHX][FOLLOWUP] Add param checking for runParallelPersonalizedPageRank
## What changes were proposed in this pull request?
add the param checking to keep in line with other algos
## How was this patch tested?
existing tests
Author: Zheng RuiFeng <ruifengz@foxmail.com>
Closes #15876 from zhengruifeng/param_check_runParallelPersonalizedPageRank.
Diffstat (limited to 'graphx/src')
-rw-r--r-- | graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala b/graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala index f4b00757a8..c0c3c73463 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala @@ -185,6 +185,13 @@ object PageRank extends Logging { def runParallelPersonalizedPageRank[VD: ClassTag, ED: ClassTag](graph: Graph[VD, ED], numIter: Int, resetProb: Double = 0.15, sources: Array[VertexId]): Graph[Vector, Double] = { + require(numIter > 0, s"Number of iterations must be greater than 0," + + s" but got ${numIter}") + require(resetProb >= 0 && resetProb <= 1, s"Random reset probability must belong" + + s" to [0, 1], but got ${resetProb}") + require(sources.nonEmpty, s"The list of sources must be non-empty," + + s" but got ${sources.mkString("[", ",", "]")}") + // TODO if one sources vertex id is outside of the int range // we won't be able to store its activations in a sparse vector val zero = Vectors.sparse(sources.size, List()).asBreeze |