简体   繁体   中英

How can I retrieve lightweight edges from OrientDB

I am creating a graph using OrientGraphNoTx in order to achieve massive insertion. After the creation I want to test if everything went well by counting the amount of nodes and edges created. As far as I know the countEdges() function don't work because the lightweight feature is enabled. So I am trying to count the edges with some custom code:

int count = 0;
for(Edge edge : orientGraph.getEdges()) {
    count++;
}

This doesn't work either. I assume that getEdges() function doesn't work either with lightweight edges. So how can I retrieve lightweight edges?

If you're really interested on browsing the edges you can disabling the lightweight edges at the cost to slow down everything. Or if it's just for test purpose you can do:

Set<Object> edges = new HashSet();
for(Vertex v : orientGraph.getVertices()) {
    for( Edge e : v.getEdges( Direction.BOTH ) )
      edges.add( e.getIdentity() );
}
return edges.size();

In this way you collect all the ids of all the edges (removing duplicates), and then return the edge's collection size.

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