orientechnologies / orientdb-gremlin

TinkerPop3 Graph Structure Implementation for OrientDB
Apache License 2.0
91 stars 32 forks source link

`V` step returns duplicate results #153

Closed To-om closed 5 years ago

To-om commented 5 years ago

The V step in a GraphTraversal returns duplicate vertices. (works as expected in a GraphTraversalSource) The number of elements seems to depends on the total number of vertices that match the previous step. The following unit test fails:

final String labelVertex = "VertexLabel";
OrientGraph graph = factory.getTx();
Vertex v1 = graph.addVertex(labelVertex);
graph.addVertex(labelVertex);
graph.tx().commit();
Assert.assertEquals(1, graph.traversal().V(v1).toList().size()); // succeeds
Assert.assertEquals(1, graph.traversal().V().V(v1).toList().size()); // fails. toList returns [v1, v1]
graph.close();
wolf4ood commented 5 years ago

Hi @To-om

i think it's not a problem of ODB. It happens also with the in memory graph implementation TinkerGraph

 @Test
  public void shouldNotReturnDuplicatesWithVStep() {
    TinkerGraph graph = TinkerFactory.createModern();
    graph.clear();
    final String labelVertex = "VertexLabel";
    Vertex v1 = graph.addVertex(labelVertex);
    graph.addVertex(labelVertex);
   //    graph.tx().commit();
    Assert.assertEquals(1, graph.traversal().V(v1).toList().size()); // succeeds
    Assert.assertEquals(1, graph.traversal().V().V(v1).toList().size()); // fails. toList returns [v1, v1]
    graph.close();
  }
To-om commented 5 years ago

Hi, I confirm this is not a bug. I misunderstand the purpose of this step. It is not a filter but a map. For each result, it retrieves the specified vertex. Thanks.