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


Java EmptyIterable类代码示例

本文整理汇总了Java中org.apache.giraph.utils.EmptyIterable的典型用法代码示例。如果您正苦于以下问题:Java EmptyIterable类的具体用法?Java EmptyIterable怎么用?Java EmptyIterable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getVertexMessagesImproved

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
public Iterable<M> getVertexMessagesImproved(I vertexId, int pId) throws IOException {

        Object2ObjectOpenHashMap<I,M[]> partitionMap = new_map[pId];
        M[] vertex_map_entry = partitionMap.get(vertexId);
        if( vertex_map_entry == null)
        {
            return EmptyIterable.get();
        }

        reentrant_locks[pId].readLock().lock();
        try {
            int current_index = getCurrentIndex(pId, vertexId);
            M result = vertex_map_entry[current_index];
            resetCurrentIndex(pId, vertexId, current_index);
            vertex_map_entry[getCurrentIndex(pId, vertexId)] = messageCombiner.createInitialMessage();
            synchronized (has_messages_map[pId]) {
                has_messages_map[pId].remove(vertexId);
            }
            return Collections.singleton(result);
        } finally {
            reentrant_locks[pId].readLock().unlock();
        }

    }
 
开发者ID:wmoustafa,项目名称:granada,代码行数:25,代码来源:OneMessagePerVertexStore.java

示例2: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
/**
 * Reads messages for a vertex. It will find the messages only if all
 * previous reads used smaller vertex ids than this one - messages should
 * be retrieved in increasing order of vertex ids.
 *
 * @param vertexId Vertex id for which we want to get messages
 * @return Messages for the selected vertex, or empty list if not used
 *         correctly
 * @throws IOException
 */
public Iterable<M> getVertexMessages(I vertexId) throws
    IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("getVertexMessages: Reading for vertex id " + vertexId +
        " (currently " + currentVertexId + ") from " + file);
  }
  if (in == null) {
    startReading();
  }

  I nextVertexId = getCurrentVertexId();
  while (nextVertexId != null && vertexId.compareTo(nextVertexId) > 0) {
    nextVertexId = getNextVertexId();
  }

  if (nextVertexId == null || vertexId.compareTo(nextVertexId) < 0) {
    return EmptyIterable.get();
  }

  return readMessagesForCurrentVertex();
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:32,代码来源:SequentialFileMessageStore.java

示例3: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
/**
 * Reads messages for a vertex. It will find the messages only if all
 * previous reads used smaller vertex ids than this one - messages should
 * be retrieved in increasing order of vertex ids.
 *
 * @param vertexId Vertex id for which we want to get messages
 * @return Messages for the selected vertex, or empty list if not used
 *         correctly
 * @throws IOException
 */
@Override
public Iterable<M> getVertexMessages(I vertexId) throws
    IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("getVertexMessages: Reading for vertex id " + vertexId +
        " (currently " + currentVertexId + ") from " + file);
  }
  if (in == null) {
    startReading();
  }

  I nextVertexId = getCurrentVertexId();
  while (nextVertexId != null && vertexId.compareTo(nextVertexId) > 0) {
    nextVertexId = getNextVertexId();
  }

  if (nextVertexId == null || vertexId.compareTo(nextVertexId) < 0) {
    return EmptyIterable.get();
  }

  return readMessagesForCurrentVertex();
}
 
开发者ID:zfighter,项目名称:giraph-research,代码行数:33,代码来源:SequentialFileMessageStore.java

示例4: computPartitionSuperstep0

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
/**
 * Compute a single partition
 *
 * @param computation Computation to use
 * @param partition Partition to compute
 */
private void computPartitionSuperstep0(Computation<I, V, E, M1, M2> computation, Partition<I, V, E> partition,
                                       PartitionStats partitionStats, long verticesComputedProgress)
        throws IOException, InterruptedException {
  
  for (Vertex<I, V, E> vertex : partition) {

    Iterable<M1> messages = new EmptyIterable<M1>();

    if (vertex.isHalted() && !Iterables.isEmpty(messages)) {
      vertex.wakeUp();
    }
    if (!vertex.isHalted()) {
      context.progress();
      //------------------------------------------------------------
      computation.compute(vertex, messages);
      compute_incovations_counter++;
      //------------------------------------------------------------
      vertex.voteToHalt();

    }
    if (vertex.isHalted()) {
      partitionStats.incrFinishedVertexCount();
    }
    // Add statistics for this vertex
    partitionStats.incrVertexCount();
    partitionStats.addEdgeCount(vertex.getNumEdges());

    verticesComputedProgress++;
    if (verticesComputedProgress == VERTICES_TO_UPDATE_PROGRESS) {
      WorkerProgress.get().addVerticesComputed(verticesComputedProgress);
      verticesComputedProgress = 0;
    }

  } //end of for
}
 
开发者ID:wmoustafa,项目名称:granada,代码行数:42,代码来源:ComputeCallable.java

示例5: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
@Override
public Iterable<M> getVertexMessages(I vertexId) throws IOException {
  if (hasMessagesForVertex(vertexId)) {
    return getMessageStore(vertexId).getVertexMessages(vertexId);
  } else {
    return EmptyIterable.get();
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:9,代码来源:DiskBackedMessageStore.java

示例6: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
@Override
public Iterable<M> getVertexMessages(
    LongWritable vertexId) throws IOException {
  DataInputOutput dataInputOutput =
      getPartitionMap(vertexId).get(vertexId.get());
  if (dataInputOutput == null) {
    return EmptyIterable.get();
  } else {
    return new MessagesIterable<M>(dataInputOutput, messageValueFactory);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:12,代码来源:LongByteArrayMessageStore.java

示例7: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
@Override
public Iterable<FloatWritable> getVertexMessages(
    IntWritable vertexId) throws IOException {
  Int2FloatOpenHashMap partitionMap = getPartitionMap(vertexId);
  if (!partitionMap.containsKey(vertexId.get())) {
    return EmptyIterable.get();
  } else {
    return Collections.singleton(
        new FloatWritable(partitionMap.get(vertexId.get())));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:12,代码来源:IntFloatMessageStore.java

示例8: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
@Override
public Iterable<DoubleWritable> getVertexMessages(
    LongWritable vertexId) throws IOException {
  Long2DoubleOpenHashMap partitionMap = getPartitionMap(vertexId);
  if (!partitionMap.containsKey(vertexId.get())) {
    return EmptyIterable.get();
  } else {
    return Collections.singleton(
        new DoubleWritable(partitionMap.get(vertexId.get())));
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:12,代码来源:LongDoubleMessageStore.java

示例9: getVertexMessages

import org.apache.giraph.utils.EmptyIterable; //导入依赖的package包/类
@Override
public Iterable<M> getVertexMessages(
    IntWritable vertexId) throws IOException {
  DataInputOutput dataInputOutput =
      getPartitionMap(vertexId).get(vertexId.get());
  if (dataInputOutput == null) {
    return EmptyIterable.get();
  } else {
    return new MessagesIterable<M>(dataInputOutput, messageValueFactory);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:12,代码来源:IntByteArrayMessageStore.java


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