Search in sources :

Example 1 with PreloadedVertex

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);
}
Also used : PreloadedVertex(org.janusgraph.graphdb.vertices.PreloadedVertex) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) EntryList(org.janusgraph.diskstorage.EntryList) Map(java.util.Map) SliceQuery(org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)

Example 2 with PreloadedVertex

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);
        }
    }
}
Also used : PreloadedVertex(org.janusgraph.graphdb.vertices.PreloadedVertex) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) MapReduce(org.apache.tinkerpop.gremlin.process.computer.MapReduce)

Example 3 with PreloadedVertex

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);
}
Also used : PreloadedVertex(org.janusgraph.graphdb.vertices.PreloadedVertex) ReadOnlyTransactionException(org.janusgraph.core.ReadOnlyTransactionException) EntryList(org.janusgraph.diskstorage.EntryList) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope)

Aggregations

PreloadedVertex (org.janusgraph.graphdb.vertices.PreloadedVertex)3 Map (java.util.Map)2 EntryList (org.janusgraph.diskstorage.EntryList)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MapReduce (org.apache.tinkerpop.gremlin.process.computer.MapReduce)1 MessageScope (org.apache.tinkerpop.gremlin.process.computer.MessageScope)1 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)1 ReadOnlyTransactionException (org.janusgraph.core.ReadOnlyTransactionException)1 SliceQuery (org.janusgraph.diskstorage.keycolumnvalue.SliceQuery)1