use of org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep in project janusgraph by JanusGraph.
the class JanusGraphTraversalUtil method getLocalMultiQueryPositionForStep.
/**
* For a MultiQuery compatible step, this method searches the correct position in the step's traversal at which
* a <code>JanusGraphMultiQueryStep</code> should be inserted. Only the traversal of the given step is considered,
* parent and child traversals are not taken into account.
* @param step The MultiQuery compatible step.
* @return The step before which a <code>JanusGraphMultiQueryStep</code> should be inserted.
* @see org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphMultiQueryStep
*/
public static Optional<Step> getLocalMultiQueryPositionForStep(Step<?, ?> step) {
Step currentStep = step;
Step previousStep = step.getPreviousStep();
while (previousStep instanceof SideEffectStep || previousStep instanceof ProfileStep) {
currentStep = previousStep;
previousStep = previousStep.getPreviousStep();
}
if (previousStep instanceof EmptyStep || previousStep instanceof StartStep) {
final Step parentStep = step.getTraversal().getParent().asStep();
if (!(parentStep instanceof RepeatStep) && isMultiQueryCompatibleParent(parentStep)) {
// no position found for JanusGraphMultiQueryStep in this local traversal
return Optional.empty();
} else {
// place JanusGraphMultiQueryStep at the stat of the local traversal
return Optional.of(currentStep);
}
} else if (previousStep instanceof NoOpBarrierStep) {
return Optional.of(previousStep);
} else {
return Optional.of(currentStep);
}
}
Aggregations