Search in sources :

Example 1 with MessageScope

use of org.apache.tinkerpop.gremlin.process.computer.MessageScope in project titan by thinkaurelius.

the class VertexProgramScanJob method process.

@Override
public void process(TitanVertex vertex, ScanMetrics metrics) {
    PreloadedVertex v = (PreloadedVertex) vertex;
    long vertexId = v.longId();
    VertexMemoryHandler<M> vh = new VertexMemoryHandler(vertexMemory, v);
    v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
    if (idManager.isPartitionedVertex(vertexId)) {
        if (idManager.isCanonicalVertexId(vertexId)) {
            EntryList results = v.getFromCache(SYSTEM_PROPS_QUERY);
            if (results == null)
                results = EntryList.EMPTY_LIST;
            vertexMemory.setLoadedProperties(vertexId, results);
        }
        for (MessageScope scope : vertexMemory.getPreviousScopes()) {
            if (scope instanceof MessageScope.Local) {
                M combinedMsg = null;
                for (Iterator<M> msgIter = vh.receiveMessages(scope).iterator(); msgIter.hasNext(); ) {
                    M msg = msgIter.next();
                    if (combinedMsg == null)
                        combinedMsg = msg;
                    else
                        combinedMsg = combiner.combine(combinedMsg, msg);
                }
                if (combinedMsg != null)
                    vertexMemory.aggregateMessage(vertexId, combinedMsg, scope);
            }
        }
    } else {
        v.setPropertyMixing(vh);
        vertexProgram.execute(v, vh, memory);
    }
}
Also used : PreloadedVertex(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope)

Example 2 with MessageScope

use of org.apache.tinkerpop.gremlin.process.computer.MessageScope in project titan by thinkaurelius.

the class VertexProgramScanJob method getQueries.

@Override
public void getQueries(QueryContainer queries) {
    if (vertexProgram instanceof TraversalVertexProgram) {
        //TraversalVertexProgram currently makes the assumption that the entire star-graph around a vertex
        //is available (in-memory). Hence, this special treatment here.
        //TODO: After TraversalVertexProgram is adjusted, remove this
        queries.addQuery().direction(Direction.BOTH).edges();
        return;
    }
    for (MessageScope scope : vertexMemory.getPreviousScopes()) {
        if (scope instanceof MessageScope.Global) {
            queries.addQuery().direction(Direction.BOTH).edges();
        } else {
            assert scope instanceof MessageScope.Local;
            TitanVertexStep<Vertex> startStep = FulgoraUtil.getReverseTitanVertexStep((MessageScope.Local) scope, queries.getTransaction());
            QueryContainer.QueryBuilder qb = queries.addQuery();
            startStep.makeQuery(qb);
            qb.edges();
        }
    }
}
Also used : PreloadedVertex(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) TraversalVertexProgram(org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope) QueryContainer(com.thinkaurelius.titan.graphdb.olap.QueryContainer)

Aggregations

PreloadedVertex (com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex)2 MessageScope (org.apache.tinkerpop.gremlin.process.computer.MessageScope)2 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)1 EntryList (com.thinkaurelius.titan.diskstorage.EntryList)1 QueryContainer (com.thinkaurelius.titan.graphdb.olap.QueryContainer)1 TraversalVertexProgram (org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1