Package org.apache.hama.graph

Examples of org.apache.hama.graph.VertexWritable


        copyTentativePageRankToBackup();
        // sum up all incoming messages for a vertex
        HashMap<VertexWritable, Double> sumMap = new HashMap<VertexWritable, Double>();
        DoubleMessage msg = null;
        while ((msg = (DoubleMessage) peer.getCurrentMessage()) != null) {
          VertexWritable k = vertexLookupMap.get(msg.getTag());
          if (k == null) {
            LOG.fatal("If you see this, partitioning has totally failed.");
          }
          if (!sumMap.containsKey(k)) {
            sumMap.put(k, msg.getData());
View Full Code Here


  @Override
  protected KeyValuePair<VertexWritable, VertexArrayWritable> processLine(
      String line) throws IOException {
    String[] split = line.split(delimiter);
    VertexWritable key = new VertexWritable(split[0]);
    VertexWritable[] v = new VertexWritable[split.length - 1];
    for (int i = 1; i < split.length; i++) {
      v[i - 1] = new VertexWritable(split[i]);
    }
    VertexArrayWritable value = new VertexArrayWritable();
    value.set(v);
    return new KeyValuePair<VertexWritable, VertexArrayWritable>(key, value);
  }
View Full Code Here

  private void generateTestTextData() throws IOException {
    BufferedWriter writer = new BufferedWriter(new FileWriter(TEXT_INPUT));
    for (Map.Entry<VertexWritable, VertexArrayWritable> e : tmp.entrySet()) {
      writer.write(e.getKey() + "\t");
      for (int i = 0; i < e.getValue().get().length; i++) {
        VertexWritable writable = (VertexWritable) e.getValue().get()[i];
        writer.write(writable.getName() + "\t");
      }
      writer.write("\n");
    }
    writer.close();
  }
View Full Code Here

  }

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

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

TOP

Related Classes of org.apache.hama.graph.VertexWritable

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.