Search in sources :

Example 1 with SqlgWhereTraversalStepBarrier

use of org.umlg.sqlg.step.barrier.SqlgWhereTraversalStepBarrier in project sqlg by pietermartin.

the class SqlgWhereTraversalStepStrategy method apply.

@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    // noinspection OptionalGetWithoutIsPresent
    if (!(traversal.getGraph().get() instanceof SqlgGraph)) {
        return;
    }
    List<WhereTraversalStep> whereTraversalSteps = TraversalHelper.getStepsOfAssignableClass(WhereTraversalStep.class, traversal);
    for (WhereTraversalStep<S> whereTraversalStep : whereTraversalSteps) {
        List<Traversal.Admin<?, ?>> whereTraversals = whereTraversalStep.getLocalChildren();
        Preconditions.checkState(whereTraversals.size() == 1);
        Traversal.Admin<?, ?> whereTraversal = whereTraversals.get(0);
        // reducing barrier steps like count does not work with Sqlg's barrier optimizations
        List<ReducingBarrierStep> reducingBarrierSteps = TraversalHelper.getStepsOfAssignableClassRecursively(ReducingBarrierStep.class, whereTraversal);
        if (!reducingBarrierSteps.isEmpty()) {
            continue;
        }
        SqlgWhereTraversalStepBarrier sqlgTraversalFilterStepBarrier = new SqlgWhereTraversalStepBarrier<>(traversal, whereTraversalStep);
        for (String label : whereTraversalStep.getLabels()) {
            sqlgTraversalFilterStepBarrier.addLabel(label);
        }
        TraversalHelper.replaceStep(whereTraversalStep, sqlgTraversalFilterStepBarrier, whereTraversalStep.getTraversal());
    }
}
Also used : SqlgGraph(org.umlg.sqlg.structure.SqlgGraph) WhereTraversalStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) SqlgWhereTraversalStepBarrier(org.umlg.sqlg.step.barrier.SqlgWhereTraversalStepBarrier) ReducingBarrierStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep)

Aggregations

Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)1 WhereTraversalStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep)1 ReducingBarrierStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep)1 SqlgWhereTraversalStepBarrier (org.umlg.sqlg.step.barrier.SqlgWhereTraversalStepBarrier)1 SqlgGraph (org.umlg.sqlg.structure.SqlgGraph)1