Hi. I have the following (Groovy) code:
ExecutionResult res = new ExecutionEngine(graphDb).execute('start from = node({from}) match from-[:IS_PART_OF]->t return t', [from: node])
println '> first traversal start'
for (def o : res) {
println o['t']
}
println '> first traversal end'
println '> second traversal start'
for (def o : res) {
println o['t']
}
println '> second traversal end'
The results are:
> first traversal start
Node[3]
> first traversal end
> second traversal start
> second traversal end
The output and my debugging results show that somehow I can only traverse the results once. ExecutionResult.iterator first returns an internal Scala iterator whose toString says 'non-empty iterator', but the second time I get an 'empty iterator'.
Is this expected behavior, or am I doing something wrong? I am using the javacompat classes. If this is expected, I think this could be documented, as normally when people see Iterable they think they can traverse the thing multiple times.
Regards,
wujek