use of org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep 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());
}
}
Aggregations