Search in sources :

Example 1 with PreloadedVertex

use of com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex in project titan by thinkaurelius.

the class VertexMapJob method process.

@Override
public void process(TitanVertex vertex, ScanMetrics metrics) {
    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;
    } else {
        for (Map.Entry<MapReduce, FulgoraMapEmitter> mapJob : mapJobs.entrySet()) {
            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(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) MapReduce(org.apache.tinkerpop.gremlin.process.computer.MapReduce)

Example 2 with PreloadedVertex

use of com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex in project titan by thinkaurelius.

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;
    }
    TitanVertex 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(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) Map(java.util.Map) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)

Example 3 with PreloadedVertex

use of com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex 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)

Aggregations

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