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