Package org.apache.hama.examples

Examples of org.apache.hama.examples.ShortestPathVertex


  @SuppressWarnings({ "rawtypes", "unchecked" })
  @Override
  protected KeyValuePair<VertexWritable, VertexArrayWritable> processLine(
      String line) throws IOException {
    String[] split = line.split(delimiter);
    ShortestPathVertex key = new ShortestPathVertex(0, split[0]);
    ShortestPathVertex[] v = new ShortestPathVertex[split.length - 1];
    for (int i = 1; i < split.length; i++) {
      String[] weightSplit = split[i].split(edgeDelimiter);
      if (weightSplit.length != 2) {
        LOG.error("Adjacent vertices must contain a \"" + edgeDelimiter
            + "\" between the vertex name and the edge weight! Line was: "
            + line);
      }
      v[i - 1] = new ShortestPathVertex(Integer.parseInt(weightSplit[1]),
          weightSplit[0]);
    }
    ShortestPathVertexArrayWritable value = new ShortestPathVertexArrayWritable();
    value.set(v);
    return new KeyValuePair(key, value);
View Full Code Here


  }

  private void verifyOutput() throws IOException {
    SequenceFile.Reader reader = new SequenceFile.Reader(fs,
        new Path(SEQ_INPUT), conf);
    ShortestPathVertex vertex = new ShortestPathVertex();
    ShortestPathVertexArrayWritable vertexArray = new ShortestPathVertexArrayWritable();

    int lines = 0;
    while (reader.next(vertex, vertexArray)) {
      int count = 0;
      assertEquals(vertex.getName(), lines + "");
      assertEquals(vertex.getWeight(), 0);
      Writable[] writables = vertexArray.get();
      assertEquals(writables.length, 5);
      for (int i = 0; i < 5; i++) {
        assertEquals(((ShortestPathVertex) writables[i]).getName(), count + "");
        assertEquals(((ShortestPathVertex) writables[i]).getWeight(), lines);
View Full Code Here

TOP

Related Classes of org.apache.hama.examples.ShortestPathVertex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.