I am using OrientDB-2.0-M2 version.
My objective is to identify whether a edge with particular label exists between a start vertex and end vertex. I am using the following method for that
private boolean existsRelationship(Relationship relationship) throws Exception
{
OrientVertex start = getVertex(relationship.getStartNodeUniqueKey());
OrientVertex end = getVertex(relationship.getEndNodeUniqueKey());
Iterator<Edge> iter = start.getEdges(end, com.tinkerpop.blueprints.Direction.OUT, relationship.getType()).iterator();
return iter.hasNext();
}
I don't know whether this approach is the efficient way to find edge existence.
In this approach, more than 60% of the CPUs time is spend in iter.hasNext() method. I am attaching the screenshot here. Pls check.
Comparing the load of millions of nodes/edges addition, I feel iter.hasNext() is tooooo expensive.
My objective is to find only the existence. For that, getting edges may not be so efficient, i feel. I am not finding OrientVertex.countEdges() method that accepts destination OrientVertex.
My Points
1. Is there any other better way of checking the existence of a edge given its startnode, end node and label???
2. You can check in the attached screenshot (taken using JMC version 5.4) whether this iter.hasNext() can be so expensive?
3. If possible, you can give some lazily loadable object in such a way that hasNext() just checks the size and current Pointer to return true or false
4. Is it possible to have OrientVertex.countEdges(OrientVertex destination, Direction direction, String... labels)