Search in sources :

Example 1 with GraphCentricQuery

use of org.janusgraph.graphdb.query.graph.GraphCentricQuery in project janusgraph by JanusGraph.

the class JanusGraphStep method buildGraphCentricQuery.

private GraphCentricQuery buildGraphCentricQuery(JanusGraphQuery query, final QueryProfiler queryProfiler) {
    Preconditions.checkArgument(query instanceof GraphCentricQueryBuilder);
    final QueryProfiler optProfiler = queryProfiler.addNested(QueryProfiler.CONSTRUCT_GRAPH_CENTRIC_QUERY);
    optProfiler.startTimer();
    final GraphCentricQueryBuilder centricQueryBuilder = ((GraphCentricQueryBuilder) query);
    if (traversal.getEndStep() instanceof CountGlobalStep) {
        centricQueryBuilder.disableSmartLimit();
    }
    final GraphCentricQuery graphCentricQuery = centricQueryBuilder.constructQueryWithoutProfile(Vertex.class.isAssignableFrom(this.returnClass) ? ElementCategory.VERTEX : ElementCategory.EDGE);
    optProfiler.stopTimer();
    return graphCentricQuery;
}
Also used : GraphCentricQueryBuilder(org.janusgraph.graphdb.query.graph.GraphCentricQueryBuilder) GraphCentricQuery(org.janusgraph.graphdb.query.graph.GraphCentricQuery) QueryProfiler(org.janusgraph.graphdb.query.profile.QueryProfiler) CountGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.CountGlobalStep)

Example 2 with GraphCentricQuery

use of org.janusgraph.graphdb.query.graph.GraphCentricQuery in project janusgraph by JanusGraph.

the class JanusGraphStep method executeGraphCentricQuery.

private void executeGraphCentricQuery(final GraphCentricQueryBuilder builder, final List<Iterator<E>> responses, final Entry<Integer, GraphCentricQuery> entry) {
    final GraphCentricQuery query = entry.getValue();
    final QueryProfiler profiler = query.getProfiler();
    final Class<? extends JanusGraphElement> graphClass = Vertex.class.isAssignableFrom(this.returnClass) ? JanusGraphVertex.class : JanusGraphEdge.class;
    final ProfiledIterator iterator = new ProfiledIterator(profiler, () -> builder.iterables(query, graphClass).iterator());
    long i = 0;
    while (i < entry.getKey() && iterator.hasNext()) {
        iterator.next();
        i++;
    }
    responses.add(iterator);
}
Also used : JanusGraphVertex(org.janusgraph.core.JanusGraphVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphCentricQuery(org.janusgraph.graphdb.query.graph.GraphCentricQuery) ProfiledIterator(org.janusgraph.graphdb.util.ProfiledIterator) QueryProfiler(org.janusgraph.graphdb.query.profile.QueryProfiler)

Aggregations

GraphCentricQuery (org.janusgraph.graphdb.query.graph.GraphCentricQuery)2 QueryProfiler (org.janusgraph.graphdb.query.profile.QueryProfiler)2 CountGlobalStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.CountGlobalStep)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)1 GraphCentricQueryBuilder (org.janusgraph.graphdb.query.graph.GraphCentricQueryBuilder)1 ProfiledIterator (org.janusgraph.graphdb.util.ProfiledIterator)1