简体   繁体   中英

OrientDB can't get edges with direction.OUT

I am trying to identify an edge having the start vertex and end vertex.

For this purpose I'm calling:

vertexStart.getEdges(Direction.OUT, relationshipId)

which seems to be always empty.

Getting the incoming edges seems to work but I need both.

vertexStart.getEdges(Direction.IN, relationshipId)

relationshipId is the label of the edge.

Iterable<Vertex> startNodes = this.getVertexList(storage.getStartNode(), graph);
            Iterable<Vertex> endNodes = this.getVertexList(storage.getEndNode(), graph);

            for (Vertex startNode : startNodes)
            {
                for (Vertex endNode : endNodes)
                {
                    String edgeClass = "class:" + storage.getId();
                    Edge edge = startNode.addEdge(edgeClass, endNode);

                    for (Map.Entry<String, Object> entry : storage.getProperties().entrySet())
                    {
                        edge.setProperty(entry.getKey(), entry.getValue());
                    }
                    edge.setProperty(Constants.TAG_HASH, HashCreator.sha1FromRelationship(storage));
                    edge.setProperty(Constants.TAG_SNAPSHOT_ID, snapshotId);
                }
            }
            graph.commit();

Is used to create the structure.

I tried to reproduce your problem and it worked in my case. I created this graph

在此处输入图片说明

The vertex #10:0 had one edge in input and one edge in output.

I used this code.

Vertex v = g.getVertex("#10:0");

System.out.println("OUT");
Iterable<Edge> itOut=v.getEdges(Direction.OUT, "E");
for(Edge e:itOut){
    System.out.println(e.getId());
}

System.out.println("IN");
Iterable<Edge> itIn=v.getEdges(Direction.IN, "E");
for(Edge e:itIn){
    System.out.println(e.getId());
}

and I got

在此处输入图片说明

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM