You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/01/14 08:00:13 UTC

[49/50] git commit: Adding minimal additional functionality to EdgeRDD

Adding minimal additional functionality to EdgeRDD


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/80e73ed0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/80e73ed0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/80e73ed0

Branch: refs/heads/master
Commit: 80e73ed0004cceb47a450c79aa4faa598502fa45
Parents: 4bafc4f
Author: Joseph E. Gonzalez <jo...@gmail.com>
Authored: Mon Jan 13 22:56:57 2014 -0800
Committer: Joseph E. Gonzalez <jo...@gmail.com>
Committed: Mon Jan 13 22:56:57 2014 -0800

----------------------------------------------------------------------
 .../scala/org/apache/spark/graphx/EdgeRDD.scala    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/80e73ed0/graphx/src/main/scala/org/apache/spark/graphx/EdgeRDD.scala
----------------------------------------------------------------------
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/EdgeRDD.scala b/graphx/src/main/scala/org/apache/spark/graphx/EdgeRDD.scala
index c0a23d1..832b781 100644
--- a/graphx/src/main/scala/org/apache/spark/graphx/EdgeRDD.scala
+++ b/graphx/src/main/scala/org/apache/spark/graphx/EdgeRDD.scala
@@ -58,6 +58,23 @@ class EdgeRDD[@specialized ED: ClassTag](
   }
 
   /**
+   * Map the values in an edge partitioning preserving the structure but changing the values.
+   *
+   * @tparam ED2 the new edge value type
+   * @param f the function from an edge to a new edge value
+   * @return a new EdgeRDD containing the new edge values
+   */
+  def mapValues[ED2: ClassTag](f: Edge[ED] => ED2): EdgeRDD[ED2] =
+    mapEdgePartitions((pid, part) => part.map(f))
+
+  /**
+   * Reverse all the edges in this RDD.
+   *
+   * @return a new EdgeRDD containing all the edges reversed
+   */
+  def reverse: EdgeRDD[ED] = mapEdgePartitions((pid, part) => part.reverse)
+
+  /**
    * Inner joins this EdgeRDD with another EdgeRDD, assuming both are partitioned using the same
    * [[PartitionStrategy]].
    *