Search in sources :

Example 1 with ProfileStep

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);
    }
}
Also used : ProfileStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep) EmptyStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep) SideEffectStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep) RepeatStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) NoOpBarrierStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep) EmptyStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) SideEffectStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep) JanusGraphVertexStep(org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphVertexStep) OptionalStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalStep) NoOpBarrierStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep) ProfileStep(org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep) RepeatStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) TraversalFilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep) BranchStep(org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep)

Aggregations

Step (org.apache.tinkerpop.gremlin.process.traversal.Step)1 BranchStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchStep)1 OptionalStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalStep)1 RepeatStep (org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep)1 TraversalFilterStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep)1 NoOpBarrierStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep)1 IdentityStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep)1 SideEffectStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep)1 StartStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep)1 EmptyStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep)1 ProfileStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep)1 JanusGraphVertexStep (org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphVertexStep)1