Skip to content

Commit 4ec77f8

Browse files
committed
Add comments about object re-use to the affected functions.
1 parent 2da5e87 commit 4ec77f8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class EdgePartition[@specialized(Char, Int, Boolean, Byte, Long, Float, Double)
5656
* Construct a new edge partition by applying the function f to all
5757
* edges in this partition.
5858
*
59+
* Be careful not to keep references to the objects passed to `f`.
60+
* To improve GC performance the same object is re-used for each call.
61+
*
5962
* @param f a function from an edge to a new attribute
6063
* @tparam ED2 the type of the new attribute
6164
* @return a new edge partition with the result of the function `f`
@@ -182,6 +185,9 @@ class EdgePartition[@specialized(Char, Int, Boolean, Byte, Long, Float, Double)
182185
/**
183186
* Get an iterator over the edges in this partition.
184187
*
188+
* Be careful not to keep references to the objects from this iterator.
189+
* To improve GC performance the same object is re-used in `next()`.
190+
*
185191
* @return an iterator over edges in the partition
186192
*/
187193
def iterator = new Iterator[Edge[ED]] {
@@ -210,6 +216,9 @@ class EdgePartition[@specialized(Char, Int, Boolean, Byte, Long, Float, Double)
210216
/**
211217
* Get an iterator over the cluster of edges in this partition with source vertex id `srcId`. The
212218
* cluster must start at position `index`.
219+
*
220+
* Be careful not to keep references to the objects from this iterator. To improve GC performance
221+
* the same object is re-used in `next()`.
213222
*/
214223
private def clusterIterator(srcId: VertexId, index: Int) = new Iterator[Edge[ED]] {
215224
private[this] val edge = new Edge[ED]

0 commit comments

Comments
 (0)