Skip to content

Commit 77a006a

Browse files
committed
Add unpersist in Graph and GraphImpl
1 parent bf1a6aa commit 77a006a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

graphx/src/main/scala/org/apache/spark/graphx/Graph.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ abstract class Graph[VD: ClassTag, ED: ClassTag] protected () extends Serializab
9696
*/
9797
def cache(): Graph[VD, ED]
9898

99+
/**
100+
* Uncaches both vertices and edges of this graph. It is useful that iterative algorithms build
101+
* a new graph in each iteration, and the vertices and edges of previous iterations are no
102+
* longer needed for following iterations.
103+
*/
104+
def unpersist(blocking: Boolean = true): Graph[VD, ED]
105+
99106
/**
100107
* Uncaches only the vertices of this graph, leaving the edges alone. This is useful in iterative
101108
* algorithms that modify the vertex attributes but reuse the edges. This method can be used to

graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected (
6565
this
6666
}
6767

68+
override def unpersist(blocking: Boolean = true): Graph[VD, ED] = {
69+
unpersistVertices(blocking)
70+
replicatedVertexView.edges.unpersist(blocking)
71+
this
72+
}
73+
6874
override def unpersistVertices(blocking: Boolean = true): Graph[VD, ED] = {
6975
vertices.unpersist(blocking)
7076
// TODO: unpersist the replicated vertices in `replicatedVertexView` but leave the edges alone

0 commit comments

Comments
 (0)