Search in sources :

Example 1 with FilterPipe

use of com.tinkerpop.pipes.filter.FilterPipe in project gremlin by tinkerpop.

the class GremlinFluentUtilityTest method testNoEdgeConstraintOptimizations.

public void testNoEdgeConstraintOptimizations() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    GremlinPipeline pipeline = new GremlinPipeline(graph.getVertex(1)).outE().sideEffect(null).inV();
    // System.out.println(pipeline);
    assertEquals(pipeline.size(), 4);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof SideEffectFunctionPipe);
    assertTrue(pipeline.get(3) instanceof InVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE().filter(null).inV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 4);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof FilterPipe);
    assertTrue(pipeline.get(3) instanceof InVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE().has("weight", 0.5).filter(null).has("date", 2012).inV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 6);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof FilterPipe);
    assertTrue(pipeline.get(4) instanceof PropertyFilterPipe);
    assertTrue(pipeline.get(5) instanceof InVertexPipe);
    // TEST OPTIMIZE(BOOLEAN) PARAMETERIZATION
    pipeline = new GremlinPipeline(graph.getVertex(1)).optimize(false).outE("knows").has("weight", 0.5).inV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 4);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof OutEdgesPipe);
    assertTrue(pipeline.get(2) instanceof PropertyFilterPipe);
    assertTrue(pipeline.get(3) instanceof InVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).optimize(true).outE("knows").has("weight", 0.5).inV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 4);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof InVertexPipe);
}
Also used : VertexQueryPipe(com.tinkerpop.pipes.transform.VertexQueryPipe) SideEffectFunctionPipe(com.tinkerpop.pipes.sideeffect.SideEffectFunctionPipe) Graph(com.tinkerpop.blueprints.Graph) PropertyFilterPipe(com.tinkerpop.pipes.filter.PropertyFilterPipe) FilterPipe(com.tinkerpop.pipes.filter.FilterPipe) RangeFilterPipe(com.tinkerpop.pipes.filter.RangeFilterPipe) PropertyFilterPipe(com.tinkerpop.pipes.filter.PropertyFilterPipe) OutEdgesPipe(com.tinkerpop.pipes.transform.OutEdgesPipe) InVertexPipe(com.tinkerpop.pipes.transform.InVertexPipe) IdentityPipe(com.tinkerpop.pipes.IdentityPipe)

Aggregations

Graph (com.tinkerpop.blueprints.Graph)1 IdentityPipe (com.tinkerpop.pipes.IdentityPipe)1 FilterPipe (com.tinkerpop.pipes.filter.FilterPipe)1 PropertyFilterPipe (com.tinkerpop.pipes.filter.PropertyFilterPipe)1 RangeFilterPipe (com.tinkerpop.pipes.filter.RangeFilterPipe)1 SideEffectFunctionPipe (com.tinkerpop.pipes.sideeffect.SideEffectFunctionPipe)1 InVertexPipe (com.tinkerpop.pipes.transform.InVertexPipe)1 OutEdgesPipe (com.tinkerpop.pipes.transform.OutEdgesPipe)1 VertexQueryPipe (com.tinkerpop.pipes.transform.VertexQueryPipe)1