Search in sources :

Example 1 with CacheVertex

use of org.janusgraph.graphdb.vertices.CacheVertex in project janusgraph by JanusGraph.

the class GhostVertexRemover method process.

@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
    long vertexId = getVertexId(key);
    assert entries.size() == 1;
    assert entries.get(everythingQueryLimit) != null;
    final EntryList everything = entries.get(everythingQueryLimit);
    if (!isGhostVertex(vertexId, everything)) {
        return;
    }
    if (everything.size() >= RELATION_COUNT_LIMIT) {
        metrics.incrementCustom(SKIPPED_GHOST_LIMIT_COUNT);
        return;
    }
    JanusGraphVertex vertex = tx.getInternalVertex(vertexId);
    Preconditions.checkArgument(vertex instanceof CacheVertex, "The bounding transaction is not configured correctly");
    CacheVertex v = (CacheVertex) vertex;
    v.loadRelations(EVERYTHING_QUERY, input -> everything);
    int removedRelations = 0;
    Iterator<JanusGraphRelation> iterator = v.query().noPartitionRestriction().relations().iterator();
    while (iterator.hasNext()) {
        iterator.next();
        iterator.remove();
        removedRelations++;
    }
    // There should be no more system relations to remove
    metrics.incrementCustom(REMOVED_VERTEX_COUNT);
    metrics.incrementCustom(REMOVED_RELATION_COUNT, removedRelations);
}
Also used : JanusGraphRelation(org.janusgraph.core.JanusGraphRelation) JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) EntryList(org.janusgraph.diskstorage.EntryList) CacheVertex(org.janusgraph.graphdb.vertices.CacheVertex)

Example 2 with CacheVertex

use of org.janusgraph.graphdb.vertices.CacheVertex in project janusgraph by JanusGraph.

the class StandardJanusGraphTx method executeMultiQuery.

public void executeMultiQuery(final Collection<InternalVertex> vertices, final SliceQuery sq, final QueryProfiler profiler) {
    LongArrayList vertexIds = new LongArrayList(vertices.size());
    for (InternalVertex v : vertices) {
        if (!v.isNew() && v.hasId() && (v instanceof CacheVertex) && !v.hasLoadedRelations(sq))
            vertexIds.add(v.longId());
    }
    if (!vertexIds.isEmpty()) {
        List<EntryList> results = QueryProfiler.profile(profiler, sq, true, q -> graph.edgeMultiQuery(vertexIds, q, txHandle));
        int pos = 0;
        for (JanusGraphVertex v : vertices) {
            if (pos < vertexIds.size() && vertexIds.get(pos) == v.longId()) {
                final EntryList vresults = results.get(pos);
                ((CacheVertex) v).loadRelations(sq, query -> vresults);
                pos++;
            }
        }
    }
}
Also used : LongArrayList(com.carrotsearch.hppc.LongArrayList) EntryList(org.janusgraph.diskstorage.EntryList) CacheVertex(org.janusgraph.graphdb.vertices.CacheVertex)

Aggregations

EntryList (org.janusgraph.diskstorage.EntryList)2 CacheVertex (org.janusgraph.graphdb.vertices.CacheVertex)2 LongArrayList (com.carrotsearch.hppc.LongArrayList)1 JanusGraphRelation (org.janusgraph.core.JanusGraphRelation)1 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)1