[ https://issues.apache.org/jira/browse/GIRAPH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403774#comment-13403774 ]
Jake Mannix commented on GIRAPH-221: ------------------------------------ @Eli, ok, I can see the fact that it's hard to figure out which method to call, making it explicit is better. @Alessandro: we used to iterate over Edge<I, E>, but we got rid of it because there are some very memory-efficient constructs (where E,I,V,M are all primitives) where instantiating extra objects is wasteful (even knowing that Iterator<Long> will involve boxing the long -> Long). I'd have to look over the discussions, but I think we started discouraging the use of the Edge<I, E> class in usercode at all, as E is the edge type, and I is the target vertex type, and all you really need is a way to look up one w.r.t. the other in a well-documented method. Since having E be null sometimes is allowed, better to iterate over I and fetch E than the reverse. So on further consideration, forget syntactic sugar, IMO it's fine to do just do for(Iterator<I> it = v.outEdgeIterator(); it.hasNext();) { I i = it.next(); ... } > Make iteration over edges more explicit > --------------------------------------- > > Key: GIRAPH-221 > URL: https://issues.apache.org/jira/browse/GIRAPH-221 > Project: Giraph > Issue Type: Improvement > Components: graph > Reporter: Alessandro Presta > Assignee: Alessandro Presta > Priority: Minor > > Is there any particular reason why BasicVertex implements Iterable? > It seems to me that doing > {code:java} > for (I neighbor : vertex) > {code} > is not that explicit, and > {code:java} > for (I neighbor : this) > {code} > gets even obscure (which may be why all examples in the codebase explicitly > instantiate an iterator and call next()). > What I propose is a more explicit > {code:java} > Iterator<I> outEdgesIterator() > {code} > and also a convenient > {code:java} > Iterable<I> outEdges() > {code} > so, for example, an algorithm can use > {code:java} > for (IntWritable neighbor : outEdges()) > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira