Streaming Results
It might be useful, and more performant, if there were an option to stream results.
Neo4J already has the concept of turning on streaming in the Content-Type header for the REST-API http://docs.neo4j.org/chunked/1.9.4/rest-api-streaming.html
It does make error responses more complicated (if an error occurs while processing results) because you'll have already responded with a 200 response when streaming starts.
I don't know if Java has the same issue, but a .Net client can have subtle memory leaks from loading very large strings into memory because any object over 85,000 gets placed onto the Large Object Heap and is not allowed to be moved in memory. Once the LOB because fragmented you can "run out of memory" if the CLR cannot find a contiguous block of free space.
Even though that would be a fairly large response, it's still something that happens and so I try to prefer to use a stream rather than to load a large string.
I know, I added it in Neo4j :)
I thought because of the rather document centric approach I'm taking here that the responses would actually be rather small.
It should be pretty simple to add streaming, I would do one row at a time.
How well does contigous streaming of JSON objects work in .net ?
Otherwise I would change the response format into:
{header}\n\r {row1}\n\r {row2}\n\r {row3}\n\r {footer}\n\r
Much like I did here: https://github.com/jexp/cypher_websocket_endpoint#sample-session
Request
{"query","start n=({ids}) return n", "params": {"ids" : [1,2]},"stats": true,"result":true}
Response:
["n"]
[{"id":1,"data":{"name":"foo"}}]
[{"id":2,"data":{"name":"bar"}}]
{"time": 0, "rows": 2, "bytes": 100}
The simplest way is to deserialize the stream into an object using a reader. You could write something that uses the reader to know when a 'row' has been read, and wrap it up into an enumerable (kinda like an iterator). Or deserialize the entire response at once, but it'd be deserialized into multiple objects, none of which is likely to be large enough to be pushed into the Large Object Heap.
Sorry for dropping the ball on this, would you want to look into it?
How would you specify the streaming? With a header? As it is a different format than the default.