Search in sources :

Example 1 with SqlgTraversalFilterStepBarrier

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

the class SqlgTraversalFilterStepStrategy method apply.

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

Aggregations

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