简体   繁体   English

如何从OrientDB中检索轻量级边缘

[英]How can I retrieve lightweight edges from OrientDB

I am creating a graph using OrientGraphNoTx in order to achieve massive insertion. 我正在使用OrientGraphNoTx创建一个图形,以实现大量插入。 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. 据我所知,countEdges()函数不起作用,因为启用了轻量级功能。 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. 我假设getEdges()函数对轻量级边缘不起作用。 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. 通过这种方式,您可以收集所有边的所有ID(删除重复项),然后返回边的集合大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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