コード例 #1
0
ファイル: PageRankVertex.java プロジェクト: YoufuLi/pregelix
    @Override
    public Vertex<VLongWritable, DoubleWritable, FloatWritable, DoubleWritable> getCurrentVertex()
        throws IOException {
      Vertex<VLongWritable, DoubleWritable, FloatWritable, DoubleWritable> vertex =
          BspUtils.createVertex(configuration);

      VLongWritable vertexId =
          new VLongWritable(inputSplit.getSplitIndex() * totalRecords + recordsRead);
      DoubleWritable vertexValue = new DoubleWritable(vertexId.get() * 10d);
      long destVertexId = (vertexId.get() + 1) % (inputSplit.getNumSplits() * totalRecords);
      float edgeValue = vertexId.get() * 100f;
      edges.put(new VLongWritable(destVertexId), new FloatWritable(edgeValue));
      vertex.initialize(vertexId, vertexValue, edges, null);
      ++recordsRead;
      if (LOG.getLevel() == Level.FINE) {
        LOG.fine(
            "next: Return vertexId="
                + vertex.getVertexId().get()
                + ", vertexValue="
                + vertex.getVertexValue()
                + ", destinationId="
                + destVertexId
                + ", edgeValue="
                + edgeValue);
      }
      return vertex;
    }
コード例 #2
0
ファイル: PageRankVertex.java プロジェクト: YoufuLi/pregelix
 @Override
 public void writeVertex(Vertex<VLongWritable, DoubleWritable, FloatWritable, ?> vertex)
     throws IOException, InterruptedException {
   getRecordWriter()
       .write(
           new Text(vertex.getVertexId().toString()),
           new Text(vertex.getVertexValue().toString()));
 }