if (steps.get(0) instanceof EdgeVertexStep) { EdgeVertexStep evs = (EdgeVertexStep)steps.get(0); if (evs.getDirection()!=Direction.BOTH) direction = evs.getDirection(); } else { assert steps.get(0) instanceof EdgeOtherVertexStep;
@Override public void close() throws Exception { closeIterator(); } }
public static <S, E> Traversal.Admin<S, E> reverse(final Traversal.Admin<S, E> traversal) { for (final Step step : traversal.getSteps()) { if (step instanceof VertexStep) ((VertexStep) step).reverseDirection(); if (step instanceof EdgeVertexStep) ((EdgeVertexStep) step).reverseDirection(); } return traversal; }
@Override public void apply(Traversal.Admin<?, ?> traversal) { UniGraph uniGraph = ((UniGraph) traversal.getGraph().get()); TraversalHelper.getStepsOfClass(EdgeOtherVertexStep.class, traversal).forEach(edgeOtherVertexStep -> { UniGraphEdgeOtherVertexStep uniGraphEdgeOtherVertexStep = new UniGraphEdgeOtherVertexStep(traversal, uniGraph, uniGraph.getControllerManager()); edgeOtherVertexStep.getLabels().forEach(uniGraphEdgeOtherVertexStep::addLabel); TraversalHelper.replaceStep(edgeOtherVertexStep, uniGraphEdgeOtherVertexStep, traversal); }); TraversalHelper.getStepsOfClass(EdgeVertexStep.class, traversal).forEach(edgeVertexStep -> { UniGraphEdgeVertexStep uniGraphEdgeVertexStep = new UniGraphEdgeVertexStep(traversal, edgeVertexStep.getDirection(), uniGraph, uniGraph.getControllerManager()); edgeVertexStep.getLabels().forEach(uniGraphEdgeVertexStep::addLabel); TraversalHelper.replaceStep(edgeVertexStep, uniGraphEdgeVertexStep, traversal); }); } }
/** * Map the {@link Edge} to its incident vertices given the direction. * * @param direction the direction to traverser from the current edge * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> toV(final Direction direction) { this.asAdmin().getBytecode().addStep(Symbols.toV, direction); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), direction)); }
/** * Map the {@link Edge} to its incident vertices. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> bothV() { this.asAdmin().getBytecode().addStep(Symbols.bothV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.BOTH)); }
if (steps.get(0) instanceof EdgeVertexStep) { EdgeVertexStep evs = (EdgeVertexStep) steps.get(0); if (evs.getDirection() != Direction.BOTH) direction = evs.getDirection(); } else { assert steps.get(0) instanceof EdgeOtherVertexStep;
/** * Map the {@link Edge} to its outgoing/tail incident {@link Vertex}. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> outV() { this.asAdmin().getBytecode().addStep(Symbols.outV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.OUT)); }
@Override public void close() throws Exception { closeIterator(); } }
public static <S, E> Traversal.Admin<S, E> reverse(final Traversal.Admin<S, E> traversal) { for (final Step step : traversal.getSteps()) { if (step instanceof VertexStep) ((VertexStep) step).reverseDirection(); if (step instanceof EdgeVertexStep) ((EdgeVertexStep) step).reverseDirection(); } return traversal; }
/** * Checks whether a given step is optimizable or not. * * @param step1 an edge-emitting step * @param step2 a vertex-emitting step * @return <code>true</code> if step1 is not labeled and emits edges and step2 emits vertices, * otherwise <code>false</code> */ private static boolean isOptimizable(final Step step1, final Step step2) { if (step1 instanceof VertexStep && ((VertexStep) step1).returnsEdge() && step1.getLabels().isEmpty()) { final Direction step1Dir = ((VertexStep) step1).getDirection(); if (step1Dir.equals(Direction.BOTH)) { return step2 instanceof EdgeOtherVertexStep; } return step2 instanceof EdgeOtherVertexStep || (step2 instanceof EdgeVertexStep && ((EdgeVertexStep) step2).getDirection().equals(step1Dir.opposite())); } return false; }
/** * Map the {@link Edge} to its incoming/head incident {@link Vertex}. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> inV() { this.asAdmin().getBytecode().addStep(Symbols.inV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.IN)); }
private Set<SchemaTableTree> appendPathForEdgeVertexStep(SchemaTableTree schemaTableTree) { EdgeVertexStep edgeVertexStep = (EdgeVertexStep) this.step; return calculatePathFromEdgeToVertex(schemaTableTree, schemaTableTree.getSchemaTable(), edgeVertexStep.getDirection()); }
final Step<Edge, Vertex> someVStep = (addsPathRequirement = step.getDirection() == Direction.BOTH) ? new EdgeOtherVertexStep(traversal) : new EdgeVertexStep(traversal, step.getDirection().opposite());
private Set<SchemaTableTree> appendPathForEdgeVertexStep(SchemaTableTree schemaTableTree) { EdgeVertexStep edgeVertexStep = (EdgeVertexStep) this.step; return calculatePathFromEdgeToVertex(schemaTableTree, schemaTableTree.getSchemaTable(), edgeVertexStep.getDirection()); }
/** * Map the {@link Edge} to its incoming/head incident {@link Vertex}. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> inV() { this.asAdmin().getBytecode().addStep(Symbols.inV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.IN)); }
/** * Checks whether a given step is optimizable or not. * * @param step1 an edge-emitting step * @param step2 a vertex-emitting step * @return <code>true</code> if step1 is not labeled and emits edges and step2 emits vertices, * otherwise <code>false</code> */ private static boolean isOptimizable(final Step step1, final Step step2) { if (step1 instanceof VertexStep && ((VertexStep) step1).returnsEdge() && step1.getLabels().isEmpty()) { final Direction step1Dir = ((VertexStep) step1).getDirection(); if (step1Dir.equals(Direction.BOTH)) { return step2 instanceof EdgeOtherVertexStep; } return step2 instanceof EdgeOtherVertexStep || (step2 instanceof EdgeVertexStep && ((EdgeVertexStep) step2).getDirection().equals(step1Dir.opposite())); } return false; }
/** * Map the {@link Edge} to its outgoing/tail incident {@link Vertex}. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> outV() { this.asAdmin().getBytecode().addStep(Symbols.outV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.OUT)); }
if (steps.get(0) instanceof EdgeVertexStep) { EdgeVertexStep evs = (EdgeVertexStep)steps.get(0); if (evs.getDirection()!=Direction.BOTH) direction = evs.getDirection(); } else { assert steps.get(0) instanceof EdgeOtherVertexStep;
/** * Map the {@link Edge} to its incident vertices. * * @return the traversal with an appended {@link EdgeVertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> bothV() { this.asAdmin().getBytecode().addStep(Symbols.bothV); return this.asAdmin().addStep(new EdgeVertexStep(this.asAdmin(), Direction.BOTH)); }