0

I have a result of a query to graphDB which returns GraphTraversal<Vertex, Map<Object, List>> values. By using the default methods values.iterate().toStream() it should return a Stream of Stream<Map<Object, List>> which I can handle as a Java8 stream, but for some reason, it does not work, repeat, by using the default methods from gemlin API to get the stream.

Note: By using a while I can iterate over it, that's fine, but I need to do some more complex operations that will be simplified by using Java8 Streams, but, as I said, is not working, even using tinkerpop default methods. Any idea?

There are no errors, but the stream is empty for some reason.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
Alter
  • 903
  • 1
  • 11
  • 27
  • Have you tried using `toList()` rather than `iterate()` ? The `iterate` terminal step includes an implicit `none` step and therefore does not return any result to the caller. Here is a related question. https://stackoverflow.com/questions/59024185/tinkerpop-gremlin-python-next-vs-iterate – Kelvin Lawrence Dec 22 '21 at 17:20

1 Answers1

1

When you call iterate() it returns a GraphTraversal and you can then call toStream() on that, but it will always be empty. You should omit the iterate() if you intend to return values to your Stream. In short, simply do values().toStream().

stephen mallette
  • 45,298
  • 5
  • 67
  • 135