Hi Adithyan, The idea of supporting a countEdges() in OrientVertex is good. Could you create a new issue for that?
Do you have lightweight edges between vertices or regular ones? Are regulars if they have at least one property. If yes you could do: select from E where out = ? and in = ? limit 1 This would be fast if you create a composite index on E (or the Edge class you're using) and fields out + in. Lvc@ On 6 November 2014 12:20, Adithyan K <[email protected]> wrote: > 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) > > -- > > --- > You received this message because you are subscribed to the Google Groups > "OrientDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
