Better way to find specific edges.

29 views
Skip to first unread message

ic...@onematch.com.br

unread,
Jun 24, 2016, 1:59:20 PM6/24/16
to Aurelius
Hello there,

I'm looking for the best way to find specific edges among some vertexes ( around 3M ). I need to check if this specific edges exists, if exists I set a property for it, if not, I create this edge.

I'm running this: 

e = g.E().has('internal_id', some_edge_id)

if(e.hasNext()) {
 
return e.next()
} else {


Daniel Kuppitz

unread,
Jun 24, 2016, 2:02:49 PM6/24/16
to aureliu...@googlegroups.com
What's the "else" part? g.E() is always bad, but since you want to create the edge if it doesn't exist, you must be aware of the adjacent vertices. Something like this would be a lot faster:

g.V(outV).outE(<label>).filter(inV().is(inV)).tryNext().orElseGet { /* create it */ }

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/126d6ff3-9d24-47d2-9aca-2031525911d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ic...@onematch.com.br

unread,
Jun 27, 2016, 1:55:12 AM6/27/16
to Aurelius
Sorry Daniel, I sent the post unintentionally without had finished it yet... So, I sent another post afterwards.

The else part just get the two vertexes involved, the "from" and the "to" and then create the edge and return the edge just created.

this function returns the edge, and another function set a property to this.

My problem is really verify if a edge exists, and return it as as i described. even when there's no edges on graph, it takes a lot of time to answer to e.hasNext(), and more time to return the e.next() when there are few edges on it...

I'll try what you put forward, just answering now to complete my post, thought that the second and complete post would be published.

Cheers.
Icaro Ponce

ic...@onematch.com.br

unread,
Jun 27, 2016, 9:03:01 AM6/27/16
to Aurelius
Coming back just to confirm that it worked for me!

Thank you guys again!
Reply all
Reply to author
Forward
0 new messages