Search code examples
javaperformanceorientdb

Navigate through a "chain" in OrientDB


Background:

I am new in OrientDB, I will test it in Java for some days to see if it is the DB that I need.

Context:

Suppose you have something similar to a LinkedList, but made with vertex and (O) edges (-):

O - O - O - O - O - O - O - O

Each vertex has a field called "name" and an edge labeled "bestFriend".

Question:

I need to print the names of all of the vertex of the "chain". Is there any way or API method to navigate through the entire list in a fast way, with a complexity < O(n)?

Thank you


Solution

  • Try something like:

    select name from ( traverse out('bestFriend') from #10:44 )
    

    Assuming #10:44 is the root vertex's id.