[ 
https://issues.apache.org/jira/browse/GIRAPH-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Roman K updated GIRAPH-174:
---------------------------

    Attachment: GIRAPH-174.patch

Both loops changed to a more convenient way.

Tested with: 
mvn test
ConnectedComponentsVertexTest JUnit test separately
                
> ConnectedComponentsVertex for loops can be replaced with for-each loops
> -----------------------------------------------------------------------
>
>                 Key: GIRAPH-174
>                 URL: https://issues.apache.org/jira/browse/GIRAPH-174
>             Project: Giraph
>          Issue Type: Improvement
>            Reporter: Jakob Homan
>            Priority: Trivial
>              Labels: newbie
>         Attachments: GIRAPH-174.patch
>
>
> {code}    // First superstep is special, because we can simply look at the 
> neighbors
>     if (getSuperstep() == 0) {
>       for (Iterator<IntWritable> edges = iterator(); edges.hasNext();) {
>         int neighbor = edges.next().get();
>         if (neighbor < currentComponent) {
>           currentComponent = neighbor;
>         }
>       }
>       // Only need to send value if it is not the own id
>       if (currentComponent != getVertexValue().get()) {
>         setVertexValue(new IntWritable(currentComponent));
>         for (Iterator<IntWritable> edges = iterator();
>             edges.hasNext();) {
>           int neighbor = edges.next().get();
>           if (neighbor > currentComponent) {
>             sendMsg(new IntWritable(neighbor), getVertexValue());
>           }
>         }
>       }{code}
> Both of the for loops in this chunk from ConnectedComponentsVertex can be 
> replaced with for(IntWritable i : iterator()) loops to be more idiomatic.

--
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

        

Reply via email to