Skip to content

Commit

Permalink
remove code dup in hybrid cut partitioner
Browse files Browse the repository at this point in the history
  • Loading branch information
atrostan committed Nov 23, 2021
1 parent 1030d91 commit 2c7a1f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/com/preprocessing/partitioning/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.preprocessing.partitioning.PartitioningType.{Hybrid, OneDim, TwoDim}
import com.preprocessing.partitioning.Util.{createPartitionDir, edgeListMatchAndPersist, hybridPartitioningPreprocess, parseArgs, persist, readEdgeList}
import org.apache.spark.{Partitioner, SparkConf, SparkContext}

// runMain com.preprocessing.partitioning.Driver --nNodes 986 --nEdges 24929 --inputFilename "src/main/resources/graphs/email-Eu-core/reset/part-00000" --outputDirectoryName "src/main/resources/graphs/email-Eu-core/partitions" --sep " " --partitioner 2 --threshold 100 --numPartitions 4 --partitionBySource "false" --isWeighted "true"
// runMain com.preprocessing.partitioning.Driver --nNodes 986 --nEdges 24929 --inputFilename "src/main/resources/graphs/email-Eu-core/compressed/part-00000" --outputDirectoryName "src/main/resources/graphs/email-Eu-core/partitions" --sep " " --partitioner 3 --threshold 100 --numPartitions 4 --partitionBySource "false" --isWeighted "true"

object Driver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ import org.apache.spark.Partitioner
class HybridCutPartitioner(nPartitions: Int, partitionBySource: Boolean) extends Partitioner {
val numPartitions = nPartitions


def getPartitionNum(u: Int, v: Int, vertexIsHighDegree: Boolean): Int = {
if (partitionBySource) {
if (vertexIsHighDegree) v % numPartitions
else u % numPartitions
} else {
if (vertexIsHighDegree) u % numPartitions
else v % numPartitions
}
}

override def getPartition(key: Any): Int = key match {
case ((u: Int, v: Int), vertexIsHighDegree: Boolean) =>
if (partitionBySource) {
if (vertexIsHighDegree) v % numPartitions
else u % numPartitions
} else {
if (vertexIsHighDegree) u % numPartitions
else v % numPartitions
}
getPartitionNum(u, v, vertexIsHighDegree)

case ((u: Int, v: Int, w: Int), vertexIsHighDegree: Boolean) =>
if (partitionBySource) {
if (vertexIsHighDegree) v % numPartitions
else u % numPartitions
} else {
if (vertexIsHighDegree) u % numPartitions
else v % numPartitions
}
getPartitionNum(u, v, vertexIsHighDegree)
}
}

0 comments on commit 2c7a1f0

Please sign in to comment.