Search in sources :

Example 1 with StartStep

use of org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep in project titan by thinkaurelius.

the class FulgoraUtil method getReverseTraversal.

private static FulgoraElementTraversal<Vertex, Edge> getReverseTraversal(final MessageScope.Local<?> scope, final TitanTransaction graph, @Nullable final Vertex start) {
    Traversal.Admin<Vertex, Edge> incident = scope.getIncidentTraversal().get().asAdmin();
    FulgoraElementTraversal<Vertex, Edge> result = FulgoraElementTraversal.of(graph);
    for (Step step : incident.getSteps()) result.addStep(step);
    Step<Vertex, ?> startStep = result.getStartStep();
    assert startStep instanceof VertexStep;
    ((VertexStep) startStep).reverseDirection();
    if (start != null)
        result.addStep(0, new StartStep<>(incident, start));
    result.asAdmin().setStrategies(FULGORA_STRATEGIES);
    return result;
}
Also used : TitanVertexStep(com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanVertexStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) TitanVertexStep(com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanVertexStep) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) OrderLocalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) FilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep) OrderGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Example 2 with StartStep

use of org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep 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)

Example 3 with StartStep

use of org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep in project janusgraph by JanusGraph.

the class FulgoraUtil method getReverseTraversal.

private static FulgoraElementTraversal<Vertex, Edge> getReverseTraversal(final MessageScope.Local<?> scope, final JanusGraphTransaction graph, @Nullable final Vertex start) {
    Traversal.Admin<Vertex, Edge> incident = scope.getIncidentTraversal().get().asAdmin();
    FulgoraElementTraversal<Vertex, Edge> result = FulgoraElementTraversal.of(graph);
    for (Step step : incident.getSteps()) result.addStep(step);
    Step<Vertex, ?> startStep = result.getStartStep();
    assert startStep instanceof VertexStep;
    ((VertexStep) startStep).reverseDirection();
    if (start != null)
        result.addStep(0, new StartStep<>(incident, start));
    result.asAdmin().setStrategies(FULGORA_STRATEGIES);
    return result;
}
Also used : JanusGraphVertexStep(org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphVertexStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) StartStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep) OrderLocalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep) Step(org.apache.tinkerpop.gremlin.process.traversal.Step) FilterStep(org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep) OrderGlobalStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep) IdentityStep(org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep) JanusGraphVertexStep(org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphVertexStep) VertexStep(org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Aggregations

Step (org.apache.tinkerpop.gremlin.process.traversal.Step)3 IdentityStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep)3 StartStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep)3 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)2 FilterStep (org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep)2 OrderGlobalStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderGlobalStep)2 OrderLocalStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.OrderLocalStep)2 VertexStep (org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep)2 Edge (org.apache.tinkerpop.gremlin.structure.Edge)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 JanusGraphVertexStep (org.janusgraph.graphdb.tinkerpop.optimize.step.JanusGraphVertexStep)2 TitanVertexStep (com.thinkaurelius.titan.graphdb.tinkerpop.optimize.TitanVertexStep)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 SideEffectStep (org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep)1 EmptyStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep)1 ProfileStep (org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep)1