Search in sources :

Example 1 with DefaultTraversalStrategies

use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies in project janusgraph by JanusGraph.

the class JanusGraphStepStrategyTest method doTest.

@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(JanusGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
Also used : TraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) TraversalStrategy(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) Test(org.junit.Test)

Example 2 with DefaultTraversalStrategies

use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies in project janusgraph by JanusGraph.

the class JanusGraphAssert method assertOptimization.

public static void assertOptimization(Traversal<?, ?> expectedTraversal, Traversal<?, ?> originalTraversal, TraversalStrategy... optimizationStrategies) {
    final TraversalStrategies optimizations = new DefaultTraversalStrategies();
    for (final TraversalStrategy<?> strategy : optimizationStrategies) {
        optimizations.addStrategies(strategy);
    }
    originalTraversal.asAdmin().setStrategies(optimizations);
    originalTraversal.asAdmin().applyStrategies();
    assertEquals(expectedTraversal.asAdmin().getSteps().toString(), originalTraversal.asAdmin().getSteps().toString());
}
Also used : TraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies)

Example 3 with DefaultTraversalStrategies

use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies in project janusgraph by JanusGraph.

the class JanusGraphStepStrategyTest method doTest.

@ParameterizedTest
@MethodSource("generateTestParameters")
public void doTest(Traversal original, Traversal optimized, Collection<TraversalStrategy> otherStrategies) {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(JanusGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : otherStrategies) {
        strategies.addStrategies(strategy);
    }
    original.asAdmin().setStrategies(strategies);
    original.asAdmin().applyStrategies();
    assertEquals(optimized, original);
}
Also used : TraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) TraversalStrategy(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with DefaultTraversalStrategies

use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies in project unipop by unipop-graph.

the class StandardStrategyProvider method get.

@Override
public TraversalStrategies get() {
    DefaultTraversalStrategies traversalStrategies = new DefaultTraversalStrategies();
    traversalStrategies.addStrategies(new UniGraphStepStrategy(), new UniGraphVertexStepStrategy(), new EdgeStepsStrategy(), new UniGraphPropertiesStrategy(), new UniGraphCoalesceStepStrategy(), new UniGraphWhereStepStrategy(), new UniGraphRepeatStepStrategy(), new UniGraphOrderStrategy());
    TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList().forEach(traversalStrategies::addStrategies);
    return traversalStrategies;
}
Also used : UniGraphStepStrategy(org.unipop.process.graph.UniGraphStepStrategy) UniGraphCoalesceStepStrategy(org.unipop.process.coalesce.UniGraphCoalesceStepStrategy) UniGraphPropertiesStrategy(org.unipop.process.properties.UniGraphPropertiesStrategy) EdgeStepsStrategy(org.unipop.process.edge.EdgeStepsStrategy) UniGraphRepeatStepStrategy(org.unipop.process.repeat.UniGraphRepeatStepStrategy) UniGraphVertexStepStrategy(org.unipop.process.vertex.UniGraphVertexStepStrategy) UniGraphOrderStrategy(org.unipop.process.order.UniGraphOrderStrategy) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) UniGraphWhereStepStrategy(org.unipop.process.where.UniGraphWhereStepStrategy)

Example 5 with DefaultTraversalStrategies

use of org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies in project janusgraph by JanusGraph.

the class JanusGraphStepStrategyTest method doMultiQueryTest.

@ParameterizedTest
@MethodSource("generateMultiQueryTestParameters")
public void doMultiQueryTest(Traversal original, Traversal expected, Collection<TraversalStrategy> otherStrategies) {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(JanusGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : otherStrategies) {
        strategies.addStrategies(strategy);
    }
    // Can't add explicitly add JanusGraphVertexStep or JanusGraphMultiQueryStep to the expected traversal so add them now
    Traversal.Admin<?, ?> optimized = expected.asAdmin();
    applyMultiQueryTraversalSteps(optimized);
    original.asAdmin().setStrategies(strategies);
    original.asAdmin().applyStrategies();
    // Tried using assertEquals(optimized, original), but if the traversal has any steps of type SideEffectStep that fails
    assertEquals(optimized.toString(), original.toString());
}
Also used : TraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) TraversalStrategy(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy) DefaultTraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

DefaultTraversalStrategies (org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies)5 TraversalStrategies (org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies)4 TraversalStrategy (org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)1 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)1 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)1 Test (org.junit.Test)1 UniGraphCoalesceStepStrategy (org.unipop.process.coalesce.UniGraphCoalesceStepStrategy)1 EdgeStepsStrategy (org.unipop.process.edge.EdgeStepsStrategy)1 UniGraphStepStrategy (org.unipop.process.graph.UniGraphStepStrategy)1 UniGraphOrderStrategy (org.unipop.process.order.UniGraphOrderStrategy)1 UniGraphPropertiesStrategy (org.unipop.process.properties.UniGraphPropertiesStrategy)1 UniGraphRepeatStepStrategy (org.unipop.process.repeat.UniGraphRepeatStepStrategy)1 UniGraphVertexStepStrategy (org.unipop.process.vertex.UniGraphVertexStepStrategy)1 UniGraphWhereStepStrategy (org.unipop.process.where.UniGraphWhereStepStrategy)1