Skip to content

Commit

Permalink
Add unpersist in Graph and GraphImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Nov 26, 2014
1 parent bf1a6aa commit 77a006a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions graphx/src/main/scala/org/apache/spark/graphx/Graph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
*/
def cache(): Graph[VD, ED]

/**
* Uncaches both vertices and edges of this graph. It is useful that iterative algorithms build
* a new graph in each iteration, and the vertices and edges of previous iterations are no
* longer needed for following iterations.
*/
def unpersist(blocking: Boolean = true): Graph[VD, ED]

/**
* Uncaches only the vertices of this graph, leaving the edges alone. This is useful in iterative
* algorithms that modify the vertex attributes but reuse the edges. This method can be used to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected (
this
}

override def unpersist(blocking: Boolean = true): Graph[VD, ED] = {
unpersistVertices(blocking)
replicatedVertexView.edges.unpersist(blocking)
this
}

override def unpersistVertices(blocking: Boolean = true): Graph[VD, ED] = {
vertices.unpersist(blocking)
// TODO: unpersist the replicated vertices in `replicatedVertexView` but leave the edges alone
Expand Down

0 comments on commit 77a006a

Please sign in to comment.