本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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
}
示例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();
}
}
示例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);
}
}
示例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())));
}
}
示例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())));
}
}
示例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);
}
}