aboutsummaryrefslogtreecommitdiff
path: root/graphx
diff options
context:
space:
mode:
authorJoseph E. Gonzalez <joseph.e.gonzalez@gmail.com>2014-05-11 18:33:46 -0700
committerMatei Zaharia <matei@databricks.com>2014-05-11 18:33:55 -0700
commitf84b7989c4d78c0142b2212c6d5badfc64b2440a (patch)
tree32ef9c1f1ad6ce2af305e838c1bf00854f28fb02 /graphx
parent2eea663f5d56e30a8a620591fc50c8891a0d81fe (diff)
downloadspark-f84b7989c4d78c0142b2212c6d5badfc64b2440a.tar.gz
spark-f84b7989c4d78c0142b2212c6d5badfc64b2440a.tar.bz2
spark-f84b7989c4d78c0142b2212c6d5badfc64b2440a.zip
Fix error in 2d Graph Partitioner
Their was a minor bug in which negative partition ids could be generated when constructing a 2D partitioning of a graph. This could lead to an inefficient 2D partition for large vertex id values. Author: Joseph E. Gonzalez <joseph.e.gonzalez@gmail.com> Closes #709 from jegonzal/fix_2d_partitioning and squashes the following commits: 937c562 [Joseph E. Gonzalez] fixing bug in 2d partitioning algorithm where negative partition ids could be generated. (cherry picked from commit f938a155b2a9c126b292d5403aca31de83d5105a) Signed-off-by: Matei Zaharia <matei@databricks.com>
Diffstat (limited to 'graphx')
-rw-r--r--graphx/src/main/scala/org/apache/spark/graphx/PartitionStrategy.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/PartitionStrategy.scala b/graphx/src/main/scala/org/apache/spark/graphx/PartitionStrategy.scala
index 0470d74cf9..1526ccef06 100644
--- a/graphx/src/main/scala/org/apache/spark/graphx/PartitionStrategy.scala
+++ b/graphx/src/main/scala/org/apache/spark/graphx/PartitionStrategy.scala
@@ -78,8 +78,8 @@ object PartitionStrategy {
override def getPartition(src: VertexId, dst: VertexId, numParts: PartitionID): PartitionID = {
val ceilSqrtNumParts: PartitionID = math.ceil(math.sqrt(numParts)).toInt
val mixingPrime: VertexId = 1125899906842597L
- val col: PartitionID = ((math.abs(src) * mixingPrime) % ceilSqrtNumParts).toInt
- val row: PartitionID = ((math.abs(dst) * mixingPrime) % ceilSqrtNumParts).toInt
+ val col: PartitionID = (math.abs(src * mixingPrime) % ceilSqrtNumParts).toInt
+ val row: PartitionID = (math.abs(dst * mixingPrime) % ceilSqrtNumParts).toInt
(col * ceilSqrtNumParts + row) % numParts
}
}