incubator-giraph-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakob Homan (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GIRAPH-174) ConnectedComponentsVertex for loops can be replaced with for-each loops
Date Sat, 07 Apr 2012 20:22:17 GMT
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


{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

        

Mime
View raw message