use of org.janusgraph.graphdb.vertices.PreloadedVertex in project janusgraph by JanusGraph.
the class VertexJobConverter method process.
@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
long vertexId = getVertexId(key);
assert entries.get(VERTEX_EXISTS_QUERY) != null;
if (isGhostVertex(vertexId, entries.get(VERTEX_EXISTS_QUERY))) {
metrics.incrementCustom(GHOST_VERTEX_COUNT);
return;
}
JanusGraphVertex vertex = tx.getInternalVertex(vertexId);
Preconditions.checkArgument(vertex instanceof PreloadedVertex, "The bounding transaction is not configured correctly");
PreloadedVertex v = (PreloadedVertex) vertex;
v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
for (Map.Entry<SliceQuery, EntryList> entry : entries.entrySet()) {
SliceQuery sq = entry.getKey();
if (sq.equals(VERTEX_EXISTS_QUERY))
continue;
EntryList entryList = entry.getValue();
if (entryList.size() >= sq.getLimit())
metrics.incrementCustom(TRUNCATED_ENTRY_LISTS);
v.addToQueryCache(sq.updateLimit(Query.NO_LIMIT), entryList);
}
job.process(v, metrics);
}
use of org.janusgraph.graphdb.vertices.PreloadedVertex in project janusgraph by JanusGraph.
the class VertexMapJob method process.
@Override
public void process(JanusGraphVertex vertex, ScanMetrics metrics) {
final PreloadedVertex v = (PreloadedVertex) vertex;
if (vertexMemory != null) {
VertexMemoryHandler vh = new VertexMemoryHandler(vertexMemory, v);
v.setPropertyMixing(vh);
}
v.setAccessCheck(MAPREDUCE_CHECK);
if (idManager.isPartitionedVertex(v.longId()) && !idManager.isCanonicalVertexId(v.longId())) {
// Only consider the canonical partition vertex representative
return;
}
for (Map.Entry<MapReduce, FulgoraMapEmitter> mapJob : mapJobs.entrySet()) {
final MapReduce job = mapJob.getKey();
try {
job.map(v, mapJob.getValue());
metrics.incrementCustom(MAP_JOB_SUCCESS);
} catch (Throwable ex) {
log.error("Encountered exception executing map job [" + job + "] on vertex [" + vertex + "]:", ex);
metrics.incrementCustom(MAP_JOB_FAILURE);
}
}
}
use of org.janusgraph.graphdb.vertices.PreloadedVertex in project janusgraph by JanusGraph.
the class VertexProgramScanJob method process.
@Override
public void process(JanusGraphVertex vertex, ScanMetrics metrics) {
PreloadedVertex v = (PreloadedVertex) vertex;
long vertexId = v.longId();
VertexMemoryHandler<M> vh = new VertexMemoryHandler(vertexMemory, v);
vh.setInExecute(true);
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> messageIterator = vh.receiveMessages(scope).iterator(); messageIterator.hasNext(); ) {
M msg = messageIterator.next();
if (combinedMsg == null)
combinedMsg = msg;
else
combinedMsg = combiner.combine(combinedMsg, msg);
}
if (combinedMsg != null)
vertexMemory.aggregateMessage(vertexId, combinedMsg, scope);
}
}
} else {
v.setPropertyMixing(vh);
try {
vertexProgram.execute(v, vh, memory);
} catch (ReadOnlyTransactionException e) {
// Ignore read-only transaction errors in FulgoraGraphComputer. In testing these errors are associated
// with cleanup of TraversalVertexProgram.HALTED_TRAVERSALS properties which can safely remain in graph.
}
}
vh.setInExecute(false);
}
Aggregations