Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading