0

I am using Titan in my Python application (connecting via RexPro & rexpro-python). I would like to perform a few operations that involve iterating over all vertices in the graph, and I'm wondering what would be the best way to do this (if there's even a sensible way at all).

The first idea that comes to mind is to request batches of g.V via the i-j filter, e.g.:

g.V[1..100]
g.V[101..200]
...
g.V[100001..100100]
...

However, the filter will load & iterate over vertices 0 to i, which will be prohibitively expensive for large graphs.

What's the best way to iterate over all vertices via RexPro?

bcm360
  • 1,437
  • 2
  • 17
  • 25

1 Answers1

1

One fairly easy solution is to use a Rexster session variable with the g.V pipe, and request batches using Pipe.next

res = conn.execute("my_iter = g.V; my_iter.next(100);", isolate=False)

while len(res) > 0:
    for d in res:
        yield d

    #get next 100
    res = conn.execute("my_iter.next(100);", isolate=False)
bcm360
  • 1,437
  • 2
  • 17
  • 25