org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement Java Examples
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultTraversal.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Set<TraverserRequirement> getTraverserRequirements() { if (null == this.requirements) { // if (!this.locked) this.applyStrategies(); this.requirements = EnumSet.noneOf(TraverserRequirement.class); for (final Step<?, ?> step : this.getSteps()) { this.requirements.addAll(step.getRequirements()); } if (!this.requirements.contains(TraverserRequirement.LABELED_PATH) && TraversalHelper.hasLabels(this)) this.requirements.add(TraverserRequirement.LABELED_PATH); if (!this.getSideEffects().keys().isEmpty()) this.requirements.add(TraverserRequirement.SIDE_EFFECTS); if (null != this.getSideEffects().getSackInitialValue()) this.requirements.add(TraverserRequirement.SACK); if (this.requirements.contains(TraverserRequirement.ONE_BULK)) this.requirements.remove(TraverserRequirement.BULK); this.requirements = Collections.unmodifiableSet(this.requirements); } return this.requirements; }
Example #2
Source File: SparkStarBarrierInterceptor.java From tinkerpop with Apache License 2.0 | 6 votes |
public static boolean isLegal(final Traversal.Admin<?, ?> traversal) { final Step<?, ?> startStep = traversal.getStartStep(); final Step<?, ?> endStep = traversal.getEndStep(); // right now this is not supported because of how the SparkStarBarrierInterceptor mutates the traversal prior to local evaluation if (traversal.getStrategies().getStrategy(SubgraphStrategy.class).isPresent()) return false; if (!startStep.getClass().equals(GraphStep.class) || ((GraphStep) startStep).returnsEdge()) return false; if (!endStep.getClass().equals(CountGlobalStep.class) && !endStep.getClass().equals(SumGlobalStep.class) && !endStep.getClass().equals(MeanGlobalStep.class) && !endStep.getClass().equals(MaxGlobalStep.class) && !endStep.getClass().equals(MinGlobalStep.class) && !endStep.getClass().equals(FoldStep.class) && !endStep.getClass().equals(GroupStep.class) && !endStep.getClass().equals(GroupCountStep.class)) // TODO: tree() return false; if (TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, Barrier.class, traversal).size() != 1) return false; if (traversal.getTraverserRequirements().contains(TraverserRequirement.SACK)) return false; return TraversalHelper.isLocalStarGraph(traversal); }
Example #3
Source File: RepeatStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Set<TraverserRequirement> getRequirements() { final Set<TraverserRequirement> requirements = this.getSelfAndChildRequirements(TraverserRequirement.BULK); if (requirements.contains(TraverserRequirement.SINGLE_LOOP)) requirements.add(TraverserRequirement.NESTED_LOOP); requirements.add(TraverserRequirement.SINGLE_LOOP); return requirements; }
Example #4
Source File: SparkSingleIterationStrategy.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void apply(final Traversal.Admin<?, ?> traversal) { final Graph graph = traversal.getGraph().orElse(EmptyGraph.instance()); // best guess at what the graph will be as its dynamically determined for (final TraversalVertexProgramStep step : TraversalHelper.getStepsOfClass(TraversalVertexProgramStep.class, traversal)) { final Traversal.Admin<?, ?> computerTraversal = step.generateProgram(graph, EmptyMemory.instance()).getTraversal().get().clone(); if (!computerTraversal.isLocked()) computerTraversal.applyStrategies(); /// boolean doesMessagePass = TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, MULTI_ITERATION_CLASSES, computerTraversal); if (!doesMessagePass) { for (final VertexStep vertexStep : TraversalHelper.getStepsOfAssignableClassRecursively(Scope.global, VertexStep.class, computerTraversal)) { if (vertexStep.returnsVertex() || !vertexStep.getDirection().equals(Direction.OUT)) { // in-edges require message pass in OLAP doesMessagePass = true; break; } } } if (!doesMessagePass && !MessagePassingReductionStrategy.endsWithElement(computerTraversal.getEndStep()) && !(computerTraversal.getTraverserRequirements().contains(TraverserRequirement.LABELED_PATH) || // TODO: remove this when dynamic detachment is available in 3.3.0 computerTraversal.getTraverserRequirements().contains(TraverserRequirement.PATH))) { // TODO: remove this when dynamic detachment is available in 3.3.0 step.setComputer(step.getComputer() // if no message passing, don't partition the loaded graph .configure(Constants.GREMLIN_SPARK_SKIP_PARTITIONER, true) // if no message passing, don't cache the loaded graph .configure(Constants.GREMLIN_SPARK_SKIP_GRAPH_CACHE, true)); } } }
Example #5
Source File: StandardVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
private static Traversal copyAndConfigureTraversal(final Traversal traversalToCopy) { final Traversal copy = traversalToCopy.asAdmin().clone(); final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(StandardVerificationStrategy.instance()); // just add a junk requirement RequirementsStrategy.addRequirements(strategies, TraverserRequirement.BULK); copy.asAdmin().setStrategies(strategies); return copy; }
Example #6
Source File: TraversalSelectStep.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements( TraverserRequirement.OBJECT, TraverserRequirement.SIDE_EFFECTS, TraverserRequirement.PATH); }
Example #7
Source File: ComputerVerificationStrategy.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void apply(final Traversal.Admin<?, ?> traversal) { if (!TraversalHelper.onGraphComputer(traversal)) return; if (traversal.getParent() instanceof TraversalVertexProgramStep) { if (TraversalHelper.getStepsOfAssignableClassRecursively(GraphStep.class, traversal).size() > 1) throw new VerificationException("Mid-traversal V()/E() is currently not supported on GraphComputer", traversal); if (TraversalHelper.hasStepOfAssignableClassRecursively(ProfileStep.class, traversal) && TraversalHelper.getStepsOfAssignableClass(VertexProgramStep.class, TraversalHelper.getRootTraversal(traversal)).size() > 1) throw new VerificationException("Profiling a multi-VertexProgramStep traversal is currently not supported on GraphComputer", traversal); } // this is a problem because sideEffect.merge() is transient on the OLAP reduction if (TraversalHelper.getRootTraversal(traversal).getTraverserRequirements().contains(TraverserRequirement.ONE_BULK)) throw new VerificationException("One bulk is currently not supported on GraphComputer: " + traversal, traversal); // you can not traverse past the local star graph with localChildren (e.g. by()-modulators). if (!TraversalHelper.isGlobalChild(traversal) && !TraversalHelper.isLocalStarGraph(traversal)) throw new VerificationException("Local traversals may not traverse past the local star-graph on GraphComputer: " + traversal, traversal); for (final Step<?, ?> step : traversal.getSteps()) { if (step instanceof PathProcessor && ((PathProcessor) step).getMaxRequirement() != PathProcessor.ElementRequirement.ID) throw new VerificationException("It is not possible to access more than a path element's id on GraphComputer: " + step + " requires " + ((PathProcessor) step).getMaxRequirement(), traversal); if (UNSUPPORTED_STEPS.stream().filter(c -> c.isAssignableFrom(step.getClass())).findFirst().isPresent()) throw new VerificationException("The following step is currently not supported on GraphComputer: " + step, traversal); } Step<?, ?> nextParentStep = traversal.getParent().asStep(); while (!(nextParentStep instanceof EmptyStep)) { if (nextParentStep instanceof PathProcessor && ((PathProcessor) nextParentStep).getMaxRequirement() != PathProcessor.ElementRequirement.ID) throw new VerificationException("The following path processor step requires more than the element id on GraphComputer: " + nextParentStep + " requires " + ((PathProcessor) nextParentStep).getMaxRequirement(), traversal); nextParentStep = nextParentStep.getNextStep(); } }
Example #8
Source File: RequirementsStrategy.java From tinkerpop with Apache License 2.0 | 5 votes |
public static void addRequirements(final TraversalStrategies traversalStrategies, final TraverserRequirement... requirements) { RequirementsStrategy strategy = (RequirementsStrategy) traversalStrategies.getStrategy(RequirementsStrategy.class).orElse(null); if (null == strategy) { strategy = new RequirementsStrategy(); traversalStrategies.addStrategies(strategy); } else { final RequirementsStrategy cloneStrategy = new RequirementsStrategy(); cloneStrategy.requirements.addAll(strategy.requirements); strategy = cloneStrategy; traversalStrategies.addStrategies(strategy); } Collections.addAll(strategy.requirements, requirements); }
Example #9
Source File: SelectOneStepTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldRequirePathsAccordingly() { Object[][] traversalPaths = new Object[][]{ {false, __.select("x").asAdmin()}, {true, __.as("x").select("x").asAdmin()}, {false, __.local(__.select("x")).asAdmin()}, {true, __.as("x").local(__.select("x")).asAdmin()}, }; for (final Object[] traversalPath : traversalPaths) { assertEquals(traversalPath[0], ((Traversal.Admin<?, ?>) traversalPath[1]).getTraverserRequirements().contains(TraverserRequirement.LABELED_PATH)); } }
Example #10
Source File: WhereStepTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldRequirePathsAccordingly() { Object[][] traversalPaths = new Object[][]{ {false, __.where(P.not(P.within("x"))).asAdmin()}, {true, __.as("x").where(P.not(P.within("x"))).asAdmin()}, {true, __.as("a").where(P.not(P.within("x"))).asAdmin()}, {false, __.local(__.where(P.not(P.within("x")))).asAdmin()}, {true, __.as("x").local(__.where(P.not(P.within("x")))).asAdmin()}, {false, __.local(__.where(P.not(P.within("x")))).asAdmin()}, }; for (final Object[] traversalPath : traversalPaths) { assertEquals(traversalPath[0], ((Traversal.Admin<?, ?>) traversalPath[1]).getTraverserRequirements().contains(TraverserRequirement.LABELED_PATH)); } }
Example #11
Source File: HasStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return EnumSet.of(TraverserRequirement.OBJECT); }
Example #12
Source File: RangeGlobalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.BULK); }
Example #13
Source File: IsStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return EnumSet.of(TraverserRequirement.OBJECT); }
Example #14
Source File: SubgraphStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return REQUIREMENTS; }
Example #15
Source File: AggregateGlobalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.BULK, TraverserRequirement.SIDE_EFFECTS); }
Example #16
Source File: SideEffectCapStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.SIDE_EFFECTS); }
Example #17
Source File: ProgramVertexProgramStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.traverserRequirements; }
Example #18
Source File: AddPropertyStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT); }
Example #19
Source File: AggregateLocalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.SIDE_EFFECTS, TraverserRequirement.BULK); }
Example #20
Source File: GroupCountSideEffectStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.BULK, TraverserRequirement.SIDE_EFFECTS); }
Example #21
Source File: SackValueStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return getSelfAndChildRequirements(TraverserRequirement.SACK); }
Example #22
Source File: PathStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.PATH); }
Example #23
Source File: PageRankVertexProgramStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return TraversalParent.super.getSelfAndChildRequirements(); }
Example #24
Source File: MinGlobalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.OBJECT); }
Example #25
Source File: AddVertexStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(); }
Example #26
Source File: EdgeOtherVertexStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.PATH); }
Example #27
Source File: SackStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.SACK); }
Example #28
Source File: CountLocalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return Collections.singleton(TraverserRequirement.OBJECT); }
Example #29
Source File: MatchStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.LABELED_PATH, TraverserRequirement.SIDE_EFFECTS); }
Example #30
Source File: LocalStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Set<TraverserRequirement> getRequirements() { return this.localTraversal.getTraverserRequirements(); }