Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies#addStrategies()
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies#addStrategies() .
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: TinkerGraphCountStrategyTest.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(TinkerGraphCountStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } if (this.optimized == null) { this.optimized = this.original.asAdmin().clone(); this.optimized.asAdmin().setStrategies(strategies); this.optimized.asAdmin().applyStrategies(); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 2
Source File: ReservedKeysVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void shouldOnlyThrow() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(ReservedKeysVerificationStrategy.build().throwException().create()); final Traversal traversal = this.traversal.asAdmin().clone(); traversal.asAdmin().setStrategies(strategies); if (allow) { traversal.asAdmin().applyStrategies(); } else { try { traversal.asAdmin().applyStrategies(); fail("The strategy should not allow vertex steps with unspecified edge labels: " + this.traversal); } catch (VerificationException ise) { assertTrue(MSG_PREDICATE.test(ise.getMessage())); } } assertTrue(logAppender.isEmpty()); }
Example 3
Source File: EdgeLabelVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void shouldOnlyThrow() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(EdgeLabelVerificationStrategy.build().throwException().create()); final Traversal traversal = this.traversal.asAdmin().clone(); traversal.asAdmin().setStrategies(strategies); if (allow) { traversal.asAdmin().applyStrategies(); } else { try { traversal.asAdmin().applyStrategies(); fail("The strategy should not allow vertex steps with unspecified edge labels: " + this.traversal); } catch (VerificationException ise) { assertTrue(MSG_PREDICATE.test(ise.getMessage())); } } assertTrue(logAppender.isEmpty()); }
Example 4
Source File: TinkerGraphCountStrategyTest.java From tinkerpop with Apache License 2.0 | 6 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(TinkerGraphCountStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } if (this.optimized == null) { this.optimized = this.original.asAdmin().clone(); this.optimized.asAdmin().setStrategies(strategies); this.optimized.asAdmin().applyStrategies(); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 5
Source File: IdentityRemovalStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
private void applyIdentityRemovalStrategy(final Traversal traversal) { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(IdentityRemovalStrategy.instance()); traversal.asAdmin().setStrategies(strategies); traversal.asAdmin().applyStrategies(); }
Example 6
Source File: HugeGraph.java From hugegraph with Apache License 2.0 | 5 votes |
public static void registerTraversalStrategies(Class<?> clazz) { TraversalStrategies strategies = null; strategies = TraversalStrategies.GlobalCache .getStrategies(Graph.class) .clone(); strategies.addStrategies(HugeVertexStepStrategy.instance(), HugeGraphStepStrategy.instance(), HugeCountStepStrategy.instance()); TraversalStrategies.GlobalCache.registerStrategies(clazz, strategies); }
Example 7
Source File: SackStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void traversersWithUnmergeableSacksShouldGenerateDiversifiedHashCodes() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(SackStrategy.build().initialValue(() -> 0).create()); final Integer[] starts = IntStream.range(0, 8192).boxed().toArray(Integer[]::new); final GraphTraversal<Integer, Long> traversal = __.inject(starts).sack(Operator.mult).sack(). map(Traverser::hashCode).dedup().count(); traversal.asAdmin().setStrategies(strategies); traversal.asAdmin().applyStrategies(); assertThat(traversal.next(), is(greaterThan(8100L))); // allow a few hash collisions }
Example 8
Source File: RepeatUnrollStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(RepeatUnrollStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 9
Source File: EdgeLabelVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldOnlyLog() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(EdgeLabelVerificationStrategy.build().logWarning().create()); final Traversal traversal = this.traversal.asAdmin().clone(); traversal.asAdmin().setStrategies(strategies); traversal.asAdmin().applyStrategies(); if (!allow) { assertTrue(String.format("Expected log entry not found in %s", logAppender.messages), logAppender.messages().anyMatch(MSG_PREDICATE)); } }
Example 10
Source File: LazyBarrierStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(LazyBarrierStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 11
Source File: TinkerGraphStepStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(TinkerGraphStepStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 12
Source File: MessagePassingReductionStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final Traversal.Admin<?, ?> rootTraversal = new DefaultGraphTraversal<>(); final TraversalVertexProgramStep parent = new TraversalVertexProgramStep(rootTraversal, this.original.asAdmin()); rootTraversal.addStep(parent.asStep()); parent.setComputerTraversal(this.original.asAdmin()); final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(MessagePassingReductionStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } rootTraversal.setStrategies(strategies); rootTraversal.asAdmin().applyStrategies(); assertEquals(this.optimized, parent.computerTraversal.get()); }
Example 13
Source File: FilterRankingStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(FilterRankingStrategy.instance()); for (final TraversalStrategy strategy : this.otherStrategies) { strategies.addStrategies(strategy); } this.original.asAdmin().setStrategies(strategies); this.original.asAdmin().applyStrategies(); assertEquals(this.optimized, this.original); }
Example 14
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 15
Source File: DefaultTraversalStrategiesTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void testCircularDependency() { //Circular dependency => throws exception TraversalStrategies s = new DefaultTraversalStrategies(); try { s.addStrategies(c, k, a, b); fail(); } catch (IllegalStateException ex) { assertTrue(ex.getMessage().toLowerCase().contains("cyclic")); } }
Example 16
Source File: DefaultTraversalStrategiesTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void testNoDependency() { //No dependency TraversalStrategies s = new DefaultTraversalStrategies(); s.addStrategies(c, a); assertEquals(2, s.toList().size()); }
Example 17
Source File: DefaultTraversalStrategiesTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void testWellDefinedDependency() { //Dependency well defined TraversalStrategies s = new DefaultTraversalStrategies(); s.addStrategies(b, a); assertEquals(2, s.toList().size()); assertEquals(a, s.toList().get(0)); assertEquals(b, s.toList().get(1)); }
Example 18
Source File: VertexProgramStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void doTest() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(new VertexProgramStrategy(Computer.compute()), ComputerVerificationStrategy.instance()); original.asAdmin().setStrategies(strategies); original.asAdmin().applyStrategies(); assertEquals(optimized, original); }
Example 19
Source File: ReservedKeysVerificationStrategyTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldOnlyLog() { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(ReservedKeysVerificationStrategy.build().logWarning().create()); final Traversal traversal = this.traversal.asAdmin().clone(); traversal.asAdmin().setStrategies(strategies); traversal.asAdmin().applyStrategies(); if (!allow) { assertTrue(String.format("Expected log entry not found in %s", logAppender.messages), logAppender.messages().anyMatch(MSG_PREDICATE)); } }
Example 20
Source File: ConnectiveStrategyTest.java From tinkerpop with Apache License 2.0 | 4 votes |
void applyConnectiveStrategy(final Traversal traversal) { final TraversalStrategies strategies = new DefaultTraversalStrategies(); strategies.addStrategies(ConnectiveStrategy.instance()); traversal.asAdmin().setStrategies(strategies); traversal.asAdmin().applyStrategies(); }