org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal Java Examples
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.util.EmptyTraversal.
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: SideEffectCapStep.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override protected E supply() { if (null == this.sideEffectCapableSteps) { this.sideEffectCapableSteps = new HashMap<>(); Traversal.Admin<?, ?> parentTraversal = this.getTraversal(); while (!(parentTraversal instanceof EmptyTraversal)) { for (final SideEffectCapable<Object, E> capableStep : TraversalHelper.getStepsOfAssignableClassRecursively(SideEffectCapable.class, parentTraversal)) { if (this.sideEffectKeys.contains(capableStep.getSideEffectKey()) && !this.sideEffectCapableSteps.containsKey(capableStep.getSideEffectKey())) this.sideEffectCapableSteps.put(capableStep.getSideEffectKey(), capableStep); } if (this.sideEffectKeys.size() == this.sideEffectCapableSteps.size()) break; parentTraversal = parentTraversal.getParent().asStep().getTraversal(); } } //////////// if (this.sideEffectKeys.size() == 1) { final String sideEffectKey = this.sideEffectKeys.get(0); final E result = this.getTraversal().getSideEffects().<E>get(sideEffectKey); final SideEffectCapable<Object, E> sideEffectCapable = this.sideEffectCapableSteps.get(sideEffectKey); final E finalResult = null == sideEffectCapable ? result : sideEffectCapable.generateFinalResult(result); this.getTraversal().getSideEffects().set(sideEffectKey, finalResult); return finalResult; } else return (E) this.getMapOfSideEffects(); }
Example #2
Source File: ComputerVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void shouldBeVerifiedIllegal() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(ComputerVerificationStrategy.instance()); this.traversal.asAdmin().setParent(new TraversalVertexProgramStep(EmptyTraversal.instance(), EmptyTraversal.instance())); // trick it this.traversal.asAdmin().setStrategies(strategies); try { this.traversal.asAdmin().applyStrategies(); if (!this.legal) fail("The traversal should not be allowed: " + this.traversal); } catch (final VerificationException ise) { if (this.legal) fail("The traversal should be allowed: " + this.traversal); } }
Example #3
Source File: TinkerGraphStepStrategyTest.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
private static GraphStep<?, ?> V(final Object... hasKeyValues) { final TinkerGraphStep<Vertex, Vertex> graphStep = new TinkerGraphStep<>(new GraphStep<>(EmptyTraversal.instance(), Vertex.class, true)); for (int i = 0; i < hasKeyValues.length; i = i + 2) { graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], (P) hasKeyValues[i + 1])); } return graphStep; }
Example #4
Source File: VertexProgramStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Parameterized.Parameters(name = "{0}") public static Iterable<Object[]> generateTestParameters() { final ComputerResultStep computerResultStep = new ComputerResultStep(EmptyTraversal.instance()); return Arrays.asList(new Traversal[][]{ {__.V().out().count(), start().addStep(traversal(__.V().out().count())).addStep(computerResultStep)}, {__.V().pageRank().out().count(), start().pageRank().asAdmin().addStep(traversal(__.V().out().count())).addStep(computerResultStep)}, {__.V().out().pageRank(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.identity())).addStep(computerResultStep)}, {__.V().out().pageRank().count(), start().addStep(traversal(__.V().out())).pageRank().asAdmin().addStep(traversal(__.count())).addStep(computerResultStep)}, {__.V().pageRank().order().limit(1), start().pageRank().asAdmin().addStep(traversal(__.V().order().limit(1))).addStep(computerResultStep)} }); }
Example #5
Source File: TinkerGraphStepStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
private static GraphStep<?, ?> V(final Object... hasKeyValues) { final TinkerGraphStep<Vertex, Vertex> graphStep = new TinkerGraphStep<>(new GraphStep<>(EmptyTraversal.instance(), Vertex.class, true)); for (int i = 0; i < hasKeyValues.length; i = i + 2) { graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], (P) hasKeyValues[i + 1])); } return graphStep; }
Example #6
Source File: Neo4jGraphStepStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
private static GraphStep<?, ?> V(final Object... hasKeyValues) { final Neo4jGraphStep<Vertex, Vertex> graphStep = new Neo4jGraphStep<>(new GraphStep<>(EmptyTraversal.instance(), Vertex.class, true)); for (int i = 0; i < hasKeyValues.length; i = i + 2) { graphStep.addHasContainer(new HasContainer((String) hasKeyValues[i], (P) hasKeyValues[i + 1])); } return graphStep; }
Example #7
Source File: EmptyStep.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public <A, B> Traversal.Admin<A, B> getTraversal() { return EmptyTraversal.instance(); }
Example #8
Source File: OrderLimitStrategyTest.java From tinkerpop with Apache License 2.0 | 4 votes |
@Test public void doTest() { traversal.asAdmin().setParent(new TraversalVertexProgramStep(EmptyTraversal.instance(), EmptyTraversal.instance())); // trick it applyOrderLimitStrategyStrategy(traversal); assertEquals(limit, TraversalHelper.getFirstStepOfAssignableClass(OrderGlobalStep.class, traversal.asAdmin()).get().getLimit()); }
Example #9
Source File: TinkerGraphCountStrategyTest.java From tinkergraph-gremlin with Apache License 2.0 | 2 votes |
private static Traversal.Admin<?, ?> countStep(final Class<? extends Element> elementClass) { return new DefaultGraphTraversal<>().addStep(new TinkerCountGlobalStep(EmptyTraversal.instance(), elementClass)); }
Example #10
Source File: TinkerGraphCountStrategyTest.java From tinkerpop with Apache License 2.0 | 2 votes |
private static Traversal.Admin<?, ?> countStep(final Class<? extends Element> elementClass) { return new DefaultGraphTraversal<>().addStep(new TinkerCountGlobalStep(EmptyTraversal.instance(), elementClass)); }