コード例 #1
0
  @SuppressWarnings("unchecked")
  @Override
  public Vertex<VLongWritable, VLongWritable, FloatWritable, VLongWritable> getCurrentVertex()
      throws IOException, InterruptedException {
    used = 0;
    if (vertex == null) vertex = (Vertex) BspUtils.createVertex(getContext().getConfiguration());
    vertex.getMsgList().clear();
    vertex.getEdges().clear();

    vertex.reset();
    Text line = getRecordReader().getCurrentValue();
    String[] fields = line.toString().split(separator);

    if (fields.length > 0) {
      /** set the src vertex id */
      long src = Long.parseLong(fields[0]);
      vertexId.set(src);
      vertex.setVertexId(vertexId);
      long dest = -1L;

      /** set up edges */
      for (int i = 1; i < fields.length; i++) {
        dest = Long.parseLong(fields[i]);
        VLongWritable destId = allocate();
        destId.set(dest);
        vertex.addEdge(destId, null);
      }
    }
    // vertex.sortEdges();
    return vertex;
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  @Override
  public Vertex<VLongWritable, Text, FloatWritable, DoubleWritable> getCurrentVertex()
      throws IOException, InterruptedException {
    if (vertex == null) {
      vertex = BspUtils.createVertex(getContext().getConfiguration());
    }
    vertex.getMsgList().clear();
    vertex.getEdges().clear();

    vertex.reset();

    /** set the src vertex id */
    vertexId.set(currentId++);
    vertex.setVertexId(vertexId);

    /** set the vertex value */
    vertex.setVertexValue(new Text("aaa"));
    return vertex;
  }