Search in sources :

Example 1 with QueryContainer

use of com.thinkaurelius.titan.graphdb.olap.QueryContainer in project titan by thinkaurelius.

the class IndexRemoveJob method getQueries.

@Override
public List<SliceQuery> getQueries() {
    if (isGlobalGraphIndex()) {
        //Everything
        return ImmutableList.of(new SliceQuery(BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(128)));
    } else {
        RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper) index;
        InternalRelationType wrappedType = wrapper.getWrappedType();
        Direction direction = null;
        for (Direction dir : Direction.values()) if (wrappedType.isUnidirected(dir))
            direction = dir;
        assert direction != null;
        StandardTitanTx tx = (StandardTitanTx) graph.get().buildTransaction().readOnly().start();
        try {
            QueryContainer qc = new QueryContainer(tx);
            qc.addQuery().type(wrappedType).direction(direction).relations();
            return qc.getSliceQueries();
        } finally {
            tx.rollback();
        }
    }
}
Also used : RelationTypeIndexWrapper(com.thinkaurelius.titan.graphdb.database.management.RelationTypeIndexWrapper) InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) Direction(org.apache.tinkerpop.gremlin.structure.Direction) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery) QueryContainer(com.thinkaurelius.titan.graphdb.olap.QueryContainer)

Example 2 with QueryContainer

use of com.thinkaurelius.titan.graphdb.olap.QueryContainer in project titan by thinkaurelius.

the class VertexProgramScanJob method getQueries.

@Override
public void getQueries(QueryContainer queries) {
    if (vertexProgram instanceof TraversalVertexProgram) {
        //TraversalVertexProgram currently makes the assumption that the entire star-graph around a vertex
        //is available (in-memory). Hence, this special treatment here.
        //TODO: After TraversalVertexProgram is adjusted, remove this
        queries.addQuery().direction(Direction.BOTH).edges();
        return;
    }
    for (MessageScope scope : vertexMemory.getPreviousScopes()) {
        if (scope instanceof MessageScope.Global) {
            queries.addQuery().direction(Direction.BOTH).edges();
        } else {
            assert scope instanceof MessageScope.Local;
            TitanVertexStep<Vertex> startStep = FulgoraUtil.getReverseTitanVertexStep((MessageScope.Local) scope, queries.getTransaction());
            QueryContainer.QueryBuilder qb = queries.addQuery();
            startStep.makeQuery(qb);
            qb.edges();
        }
    }
}
Also used : PreloadedVertex(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) TraversalVertexProgram(org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope) QueryContainer(com.thinkaurelius.titan.graphdb.olap.QueryContainer)

Aggregations

QueryContainer (com.thinkaurelius.titan.graphdb.olap.QueryContainer)2 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)1 SliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)1 RelationTypeIndexWrapper (com.thinkaurelius.titan.graphdb.database.management.RelationTypeIndexWrapper)1 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)1 StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)1 PreloadedVertex (com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex)1 MessageScope (org.apache.tinkerpop.gremlin.process.computer.MessageScope)1 TraversalVertexProgram (org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram)1 Direction (org.apache.tinkerpop.gremlin.structure.Direction)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1