From 084ae5a80c96cb481c2b7d3f5aced99b09619057 Mon Sep 17 00:00:00 2001 From: Takeshi YAMAMURO Date: Fri, 17 Apr 2015 13:05:13 +0900 Subject: [PATCH 1/2] Add getPartitionStrategy --- graphx/src/main/scala/org/apache/spark/graphx/Graph.scala | 3 +++ .../main/scala/org/apache/spark/graphx/impl/GraphImpl.scala | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/graphx/src/main/scala/org/apache/spark/graphx/Graph.scala b/graphx/src/main/scala/org/apache/spark/graphx/Graph.scala index 36dc7b0f86c89..174123a7ac532 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/Graph.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/Graph.scala @@ -79,6 +79,9 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab */ @transient val triplets: RDD[EdgeTriplet[VD, ED]] + /** Return a strategy to specify how edges are partitioned. */ + def getPartitionStrategy: Option[PartitionStrategy] + /** * Caches the vertices and edges associated with this graph at the specified storage level, * ignoring any target storage levels previously set. diff --git a/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala b/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala index 90a74d23a26cc..1656ceeb73084 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala @@ -53,6 +53,10 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected ( }) } + @transient var partitionStrategy: Option[PartitionStrategy] = None + + override def getPartitionStrategy: Option[PartitionStrategy] = partitionStrategy + override def persist(newLevel: StorageLevel): Graph[VD, ED] = { vertices.persist(newLevel) replicatedVertexView.edges.persist(newLevel) @@ -99,6 +103,7 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected ( override def partitionBy( partitionStrategy: PartitionStrategy, numPartitions: Int): Graph[VD, ED] = { + this.partitionStrategy = Some(partitionStrategy) val edTag = classTag[ED] val vdTag = classTag[VD] val newEdges = edges.withPartitionsRDD(edges.map { e => From c46d126a044d089f70b1c38b3cdb4979b6ffe589 Mon Sep 17 00:00:00 2001 From: Takeshi YAMAMURO Date: Fri, 17 Apr 2015 13:54:38 +0900 Subject: [PATCH 2/2] Add an new entry in MimaExlucdes.scala --- project/MimaExcludes.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project/MimaExcludes.scala b/project/MimaExcludes.scala index 1564babefa62f..c54dc18b5f168 100644 --- a/project/MimaExcludes.scala +++ b/project/MimaExcludes.scala @@ -68,8 +68,13 @@ object MimaExcludes { // SPARK-6693 add tostring with max lines and width for matrix ProblemFilters.exclude[MissingMethodProblem]( "org.apache.spark.mllib.linalg.Matrix.toString") + )++ Seq( + // SPARK-5352 Add getPartitionStrategy in Graph + ProblemFilters.exclude[MissingMethodProblem]( + "org.apache.spark.graphx.Graph.getPartitionStrategy") ) + case v if v.startsWith("1.3") => Seq( MimaBuild.excludeSparkPackage("deploy"),