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());
}
}
Aggregations