Hi Patrick,
In your case should work also this one:

select expand( out('REL_Account_Company').Id[value =
'd2b03eae-4c22-e411-8534-00155d016d32'] )
from Account
where Id = 'd236e1f3-5022-e411-8534-00155d016d32'

Lvc@

On 3 April 2015 at 18:36, Patrick Hoeffel <[email protected]> wrote:

> There is probably a better way to do this (which I would be happy to
> know), but this seems to currently be working for me in a Javascript
> function inside OrientDB. I have not yet tried indexing the edges, but I
> have tried several variations of Luca's suggestion below, without any luck.
> I do have an index on the Id field of each Vertex (every vertex type has an
> Id field).
>
> function edgeExists(fromId, toId, edgeClassName, fromClassName) {
>   var result = db.command("select FROM (select expand(out('"+edgeClassName
> +"').Id) from "+fromClassName+" where Id = '"+fromId+"') where value = '"+
> toId+"'");
>   if (result.length == 0)
>     return false;
>   else
>     return true;
> }
>
>
> At runtime it expands to this:
>
> select FROM (select expand(out('REL_Account_Company').Id) from Account
> where Id = 'd236e1f3-5022-e411-8534-00155d016d32') where value =
> 'd2b03eae-4c22-e411-8534-00155d016d32'
>
> Always open to suggestions, especially since this will get called a lot.
>
> Patrick
>
>
>
> On Thursday, November 6, 2014 at 4:20:09 AM UTC-7, Adithyan K 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.

Reply via email to