Possible to do pagination with same traversal instance Golang SDK?

44 views
Skip to first unread message

Laura Poss

unread,
May 7, 2024, 8:13:07 PMMay 7
to Gremlin-users
Hi,

I'm looking at the pagination section of the Tinkerpop docs and it has this example of using the same traversal instance to avoid needing to repeat traversing prior results:

gremlin> t = g.V().hasLabel('person');[] gremlin> t.next(2) ==>v[1] ==>v[2] gremlin> t.next(2) ==>v[4] ==>v[6]

Does anyone know if it's possible to do something like this using the gremlingo Golang SDK? The graph traversal Next function declaration doesn't accept parameters:
func (t *gremlingo.Traversal) Next() (*gremlingo.Result, error)

Any guidance is appreciated!

Ken Hu

unread,
May 9, 2024, 1:03:56 PMMay 9
to Gremlin-users
It looks like you are right that next(n) isn't implemented for gremlin-go. However, the implemention of next(n) in most other language variants simply calls next() function n times and appends the result to a list/array. There is no other optimization done so you could write your own function that has the same behavior.

Laura Poss

unread,
May 9, 2024, 5:59:29 PMMay 9
to Gremlin-users
Cool, makes sense, thanks!
Reply all
Reply to author
Forward
0 new messages