Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Edward J. Yoon: Graph computing with Apache Hama

$
0
0
Today, the Pregel-like graph programming framework has been committed into TRUNK. Interfaces are not elegant yet, but I'm sure that Apache Hama will provide best performance than others e.g., Giraph, GoldenOrb. :D ( Hama Performance Benchmarks: http://wiki.apache.org/hama/Benchmarks )

Here's Hama version Single Shortest Path algorithm, it's the same as described in Google's Pregel paper:

  public static class ShortestPathVertex extends Vertex<IntegerMessage> {
    public ShortestPathVertex() {
      super(IntegerMessage.class);
      this.setValue(Integer.MAX_VALUE);
    }

    public boolean isStartVertex() {
      String startVertex = getConf().get(START_VERTEX);
      return (this.getVertexID().equals(startVertex)) ? true : false;
    }

    @Override
    public void compute(Iterator<IntegerMessage> messages) throws IOException {
      int minDist = isStartVertex() ? 0 : Integer.MAX_VALUE;

      while (messages.hasNext()) {
        IntegerMessage msg = messages.next();
        if (msg.getData() < minDist) {
          minDist = msg.getData();
        }
      }

      if (minDist < (Integer) this.getValue()) {
        this.setValue(minDist);
        for (Edge e : this.getOutEdges()) {
          sendMessage(e.getTarget(), new IntegerMessage(e.getName(), minDist
              + e.getCost()));
        }
      }
    }
  }

Viewing all articles
Browse latest Browse all 9364

Trending Articles