Java Code Examples for org.apache.tinkerpop.gremlin.process.computer.MessageScope#Global

The following examples show how to use org.apache.tinkerpop.gremlin.process.computer.MessageScope#Global . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VertexMemoryHandler.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: VertexMemoryHandler.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Override
public Stream<M> receiveMessages(MessageScope messageScope) {
    if (messageScope instanceof MessageScope.Global) {
        return super.receiveMessages(messageScope);
    } else {
        final MessageScope.Local<M> localMessageScope = (MessageScope.Local) messageScope;
        M aggregateMsg = vertexMemory.getAggregateMessage(vertexId,localMessageScope);
        if (aggregateMsg==null) return Stream.empty();
        else return Stream.of(aggregateMsg);
    }
}
 
Example 3
Source File: FulgoraVertexMemory.java    From titan1withtp3.1 with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 4
Source File: FulgoraVertexMemory.java    From titan1withtp3.1 with Apache License 2.0 4 votes vote down vote up
private static MessageScope normalizeScope(MessageScope scope) {
    if (scope instanceof MessageScope.Global) return GLOBAL_SCOPE;
    else return scope;
}