Home > OS >  Convert GraphTraversal<Vertex, Map<Object, List>> into Java8 stream
Convert GraphTraversal<Vertex, Map<Object, List>> into Java8 stream

Time:12-23

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 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.

CodePudding user response:

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().

  • Related