当前位置: 首页>>代码示例>>Java>>正文


Java VertexReader.nextVertex方法代码示例

本文整理汇总了Java中org.apache.giraph.io.VertexReader.nextVertex方法的典型用法代码示例。如果您正苦于以下问题:Java VertexReader.nextVertex方法的具体用法?Java VertexReader.nextVertex怎么用?Java VertexReader.nextVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.giraph.io.VertexReader的用法示例。


在下文中一共展示了VertexReader.nextVertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readInputSplit

import org.apache.giraph.io.VertexReader; //导入方法依赖的package包/类
/**
 * Read vertices from input split.  If testing, the user may request a
 * maximum number of vertices to be read from an input split.
 *
 * @param inputSplit Input split to process with vertex reader
 * @param graphState Current graph state
 * @return Vertices and edges loaded from this input split
 * @throws IOException
 * @throws InterruptedException
 */
@Override
protected VertexEdgeCount readInputSplit(
    InputSplit inputSplit,
    GraphState<I, V, E, M> graphState)
  throws IOException, InterruptedException {
  VertexInputFormat<I, V, E> vertexInputFormat =
      configuration.createVertexInputFormat();
  VertexReader<I, V, E> vertexReader =
      vertexInputFormat.createVertexReader(inputSplit, context);
  vertexReader.setConf(
      (ImmutableClassesGiraphConfiguration<I, V, E, Writable>) configuration);
  vertexReader.initialize(inputSplit, context);
  long inputSplitVerticesLoaded = 0;
  long edgesSinceLastUpdate = 0;
  long inputSplitEdgesLoaded = 0;
  while (vertexReader.nextVertex()) {
    Vertex<I, V, E, M> readerVertex =
        (Vertex<I, V, E, M>) vertexReader.getCurrentVertex();
    if (readerVertex.getId() == null) {
      throw new IllegalArgumentException(
          "readInputSplit: Vertex reader returned a vertex " +
              "without an id!  - " + readerVertex);
    }
    if (readerVertex.getValue() == null) {
      readerVertex.setValue(configuration.createVertexValue());
    }
    readerVertex.setConf(configuration);
    readerVertex.setGraphState(graphState);

    PartitionOwner partitionOwner =
        bspServiceWorker.getVertexPartitionOwner(readerVertex.getId());
    graphState.getWorkerClientRequestProcessor().sendVertexRequest(
        partitionOwner, readerVertex);
    context.progress(); // do this before potential data transfer
    ++inputSplitVerticesLoaded;
    edgesSinceLastUpdate += readerVertex.getNumEdges();

    // Update status every VERTICES_UPDATE_PERIOD vertices
    if (inputSplitVerticesLoaded % VERTICES_UPDATE_PERIOD == 0) {
      totalVerticesMeter.mark(VERTICES_UPDATE_PERIOD);
      totalEdgesMeter.mark(edgesSinceLastUpdate);
      inputSplitEdgesLoaded += edgesSinceLastUpdate;
      edgesSinceLastUpdate = 0;

      LoggerUtils.setStatusAndLog(
          context, LOG, Level.INFO,
          "readVertexInputSplit: Loaded " +
              totalVerticesMeter.count() + " vertices at " +
              totalVerticesMeter.meanRate() + " vertices/sec " +
              totalEdgesMeter.count() + " edges at " +
              totalEdgesMeter.meanRate() + " edges/sec " +
              MemoryUtils.getRuntimeMemoryStats());
    }

    // For sampling, or to limit outlier input splits, the number of
    // records per input split can be limited
    if (inputSplitMaxVertices > 0 &&
        inputSplitVerticesLoaded >= inputSplitMaxVertices) {
      if (LOG.isInfoEnabled()) {
        LOG.info("readInputSplit: Leaving the input " +
            "split early, reached maximum vertices " +
            inputSplitVerticesLoaded);
      }
      break;
    }
  }
  vertexReader.close();
  return new VertexEdgeCount(inputSplitVerticesLoaded,
      inputSplitEdgesLoaded + edgesSinceLastUpdate);
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:81,代码来源:VertexInputSplitsCallable.java


注:本文中的org.apache.giraph.io.VertexReader.nextVertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。