Search in sources :

Example 1 with BothVerticesPipe

use of com.tinkerpop.pipes.transform.BothVerticesPipe in project gremlin by tinkerpop.

the class GremlinFluentUtilityTest method testVertexQueryOptimization.

public void testVertexQueryOptimization() {
    Graph graph = TinkerGraphFactory.createTinkerGraph();
    GremlinPipeline pipeline = new GremlinPipeline(graph.getVertex(1)).outE().inV();
    // System.out.println(pipeline);
    assertEquals(pipeline.size(), 3);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof InVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE()._().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);
    pipeline = new GremlinPipeline(graph.getVertex(1)).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);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE("knows").has("weight", 0.5).interval("since", 10, 2).inV();
    // System.out.println(pipeline);
    assertEquals(pipeline.size(), 5);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof IdentityPipe);
    assertTrue(pipeline.get(4) instanceof InVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE("knows").has("weight", 0.5).interval("since", 10, 2).outV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 5);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof IdentityPipe);
    assertTrue(pipeline.get(4) instanceof OutVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).inE("knows", "created").has("weight", 0.5).interval("since", 10, 2).outV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 5);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof IdentityPipe);
    assertTrue(pipeline.get(4) instanceof OutVertexPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).bothE("knows", "created").has("weight", 0.5).interval("since", 10, 2).bothV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 5);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof IdentityPipe);
    assertTrue(pipeline.get(4) instanceof BothVerticesPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).bothE("knows", "created").has("weight", 0.5)._().interval("since", 10, 2).bothV();
    //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 IdentityPipe);
    assertTrue(pipeline.get(4) instanceof IdentityPipe);
    assertTrue(pipeline.get(5) instanceof BothVerticesPipe);
    pipeline = new GremlinPipeline(graph.getVertex(1)).outE("knows", "created").has("weight", 0.5)._().interval("since", 10, 2).range(1, 10).bothV();
    //System.out.println(pipeline);
    assertEquals(pipeline.size(), 7);
    assertTrue(pipeline.get(0) instanceof GremlinStartPipe);
    assertTrue(pipeline.get(1) instanceof VertexQueryPipe);
    assertTrue(pipeline.get(2) instanceof IdentityPipe);
    assertTrue(pipeline.get(3) instanceof IdentityPipe);
    assertTrue(pipeline.get(4) instanceof IdentityPipe);
    assertTrue(pipeline.get(5) instanceof IdentityPipe);
    assertTrue(pipeline.get(6) instanceof BothVerticesPipe);
}
Also used : VertexQueryPipe(com.tinkerpop.pipes.transform.VertexQueryPipe) Graph(com.tinkerpop.blueprints.Graph) BothVerticesPipe(com.tinkerpop.pipes.transform.BothVerticesPipe) InVertexPipe(com.tinkerpop.pipes.transform.InVertexPipe) IdentityPipe(com.tinkerpop.pipes.IdentityPipe) OutVertexPipe(com.tinkerpop.pipes.transform.OutVertexPipe)

Aggregations

Graph (com.tinkerpop.blueprints.Graph)1 IdentityPipe (com.tinkerpop.pipes.IdentityPipe)1 BothVerticesPipe (com.tinkerpop.pipes.transform.BothVerticesPipe)1 InVertexPipe (com.tinkerpop.pipes.transform.InVertexPipe)1 OutVertexPipe (com.tinkerpop.pipes.transform.OutVertexPipe)1 VertexQueryPipe (com.tinkerpop.pipes.transform.VertexQueryPipe)1