janusgraph icon indicating copy to clipboard operation
janusgraph copied to clipboard

Stream g.V(v).outE() results

Open li-boxuan opened this issue 3 years ago • 6 comments

See https://lists.lfaidata.foundation/g/janusgraph-users/topic/88677270#6380

g.E().hasNext() is fast, and that’s because the results are streamed. On the other hand, g.V(v0).outE().hasNext() is slow if vertex v0 has a huge amount of incident edges, and that’s because the results, in this case, are not streamed. It definitely needs some investigation, but usually, it’s not a big problem because people don’t expect a large number of incident edges attached to a node.

li-boxuan avatar Feb 01 '22 05:02 li-boxuan

I did not see any further response on the mailing list about the usage of limit(). Does it mitigate the issue to use limit() right before hasNext()?

rngcntr avatar Feb 01 '22 07:02 rngcntr

I did not see any further response on the mailing list about the usage of limit(). Does it mitigate the issue to use limit() right before hasNext()?

think you mean range(). sure, that can be done but that can be done with virtually all calls and but the burden shifts to the caller. given that streaming is already a concept used elsewhere in the system, why not make it available everywhere for the benefit of all callers.

nguyenm100 avatar Feb 01 '22 12:02 nguyenm100

My point was that if this solves the issue, it would be an easy fix to deploy a strategy which replaces hasNext() by limit(1).hasNext() in every traversal.

rngcntr avatar Feb 01 '22 12:02 rngcntr

My point was that if this solves the issue, it would be an easy fix to deploy a strategy which replaces hasNext() by limit(1).hasNext() in every traversal.

again, I think you mean range(0,1), range(1,2), etc. unless limit() is stateful?

nguyenm100 avatar Feb 01 '22 12:02 nguyenm100

limit is not stateful. @rngcntr limit(1).hasNext() is very handy when the user just wants to know the existence, but the original problem as stated in the mailing list is that the user wants to iterate over all results as a stream.

li-boxuan avatar Feb 01 '22 13:02 li-boxuan

Alright, got it. Thanks for the clarification!

rngcntr avatar Feb 01 '22 13:02 rngcntr