Expected use of `next()` in Java driver
I was doing some testing recently and noticed that on very large datasets, invoking
next()
seems to pull everything and not just the first element like I thought it would.
I have noticed this used a lot as a way of effectively doing <traversal>.limit(1)
.
Is it expected if you are using next()
that you then close()
the traversal that you called next()
on?
I tried looking in the docs but since it implements iterator I couldn't find the docs for actually using next()
2 Replies
next()
does not trigger another "get" of one from the server. if you want 1 then you should do limit(1).next()
if you do g.V().next()
it's going to stream all of V()
to the client in batches and that next()
is just going to return the first one. if you never call next()
again it will still be busy streaming all that stuff to the clientah that makes sense, thanks