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);
}
}
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();
}
}
}
Aggregations