本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.computer.MessageScope.Global方法的典型用法代码示例。如果您正苦于以下问题:Java MessageScope.Global方法的具体用法?Java MessageScope.Global怎么用?Java MessageScope.Global使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.computer.MessageScope
的用法示例。
在下文中一共展示了MessageScope.Global方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
@Override
public void sendMessage(final MessageScope messageScope, final M message) {
if (messageScope instanceof MessageScope.Local) {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
final Traversal.Admin<Vertex, Edge> incidentTraversal = GiraphMessenger.setVertexStart(localMessageScope.getIncidentTraversal().get().asAdmin(), this.giraphVertex.getValue().get());
final Direction direction = GiraphMessenger.getOppositeDirection(incidentTraversal);
incidentTraversal.forEachRemaining(edge ->
this.giraphComputation.sendMessage(
new ObjectWritable<>(edge.vertices(direction).next().id()),
new ObjectWritable<>(localMessageScope.getEdgeFunction().apply(message, edge))));
} else {
final MessageScope.Global globalMessageScope = (MessageScope.Global) messageScope;
globalMessageScope.vertices().forEach(vertex ->
this.giraphComputation.sendMessage(new ObjectWritable<>(vertex.id()), new ObjectWritable<>(message)));
}
}
示例2: receiveMessages
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
public Stream<M> receiveMessages(MessageScope messageScope) {
if (messageScope instanceof MessageScope.Global) {
M message = vertexMemory.getMessage(vertexId,messageScope);
if (message == null) return Stream.empty();
else return Stream.of(message);
} else {
final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
final Traversal<Vertex, Edge> reverseIncident = FulgoraUtil.getReverseElementTraversal(localMessageScope,vertex,vertex.tx());
final BiFunction<M,Edge,M> edgeFct = localMessageScope.getEdgeFunction();
return IteratorUtils.stream(reverseIncident)
.map(e -> {
M msg = vertexMemory.getMessage(vertexMemory.getCanonicalId(((TitanEdge) e).otherVertex(vertex).longId()), localMessageScope);
return msg == null ? null : edgeFct.apply(msg, e);
})
.filter(m -> m != null);
}
}
示例3: sendMessage
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
void sendMessage(long vertexId, M message, MessageScope scope) {
VertexState<M> state = get(vertexId,true);
if (scope instanceof MessageScope.Global) state.addMessage(message,GLOBAL_SCOPE,currentScopes,combiner);
else state.setMessage(message,scope,currentScopes);
}
示例4: normalizeScope
import org.apache.tinkerpop.gremlin.process.computer.MessageScope; //导入方法依赖的package包/类
private static MessageScope normalizeScope(MessageScope scope) {
if (scope instanceof MessageScope.Global) return GLOBAL_SCOPE;
else return scope;
}