Search in sources :

Example 1 with CacheVertex

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

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;
    }
    TitanVertex vertex = tx.getInternalVertex(vertexId);
    Preconditions.checkArgument(vertex instanceof CacheVertex, "The bounding transaction is not configured correctly");
    CacheVertex v = (CacheVertex) vertex;
    v.loadRelations(EVERYTHING_QUERY, new Retriever<SliceQuery, EntryList>() {

        @Override
        public EntryList get(SliceQuery input) {
            return everything;
        }
    });
    int removedRelations = 0;
    Iterator<TitanRelation> iter = v.query().noPartitionRestriction().relations().iterator();
    while (iter.hasNext()) {
        iter.next();
        iter.remove();
        removedRelations++;
    }
    //There should be no more system relations to remove
    metrics.incrementCustom(REMOVED_VERTEX_COUNT);
    metrics.incrementCustom(REMOVED_RELATION_COUNT, removedRelations);
}
Also used : TitanVertex(com.thinkaurelius.titan.core.TitanVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) CacheVertex(com.thinkaurelius.titan.graphdb.vertices.CacheVertex) TitanRelation(com.thinkaurelius.titan.core.TitanRelation) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)

Example 2 with CacheVertex

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

the class StandardTitanTx method executeMultiQuery.

public void executeMultiQuery(final Collection<InternalVertex> vertices, final SliceQuery sq, final QueryProfiler profiler) {
    LongArrayList vids = new LongArrayList(vertices.size());
    for (InternalVertex v : vertices) {
        if (!v.isNew() && v.hasId() && (v instanceof CacheVertex) && !v.hasLoadedRelations(sq))
            vids.add(v.longId());
    }
    if (!vids.isEmpty()) {
        List<EntryList> results = QueryProfiler.profile(profiler, sq, true, q -> graph.edgeMultiQuery(vids, q, txHandle));
        int pos = 0;
        for (TitanVertex v : vertices) {
            if (pos < vids.size() && vids.get(pos) == v.longId()) {
                final EntryList vresults = results.get(pos);
                ((CacheVertex) v).loadRelations(sq, new Retriever<SliceQuery, EntryList>() {

                    @Override
                    public EntryList get(SliceQuery query) {
                        return vresults;
                    }
                });
                pos++;
            }
        }
    }
}
Also used : LongArrayList(com.carrotsearch.hppc.LongArrayList) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) CacheVertex(com.thinkaurelius.titan.graphdb.vertices.CacheVertex) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)

Aggregations

EntryList (com.thinkaurelius.titan.diskstorage.EntryList)2 SliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)2 CacheVertex (com.thinkaurelius.titan.graphdb.vertices.CacheVertex)2 LongArrayList (com.carrotsearch.hppc.LongArrayList)1 TitanRelation (com.thinkaurelius.titan.core.TitanRelation)1 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)1