You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2009/07/29 20:30:33 UTC

sending head of a view result in one chunk

Following discussion on irc  I post here my problem. I am currently
implementing a feature allowing me to parse the view while it's coming
over http.  Using chunks allow me to parse each line easily. It
currently work but currently first line of view is sent with the
header. It would be better imo to send the header and the first line
in different chunks, so It isn't needed to split the result. What do
you think about it ? I could eventually sending a patch that would do
the trick. Please let me know/

Here is a snippet using ecouchdbkit that show how a view is parsed in
a streaming fashion :

http://friendpaste.com/uBCLsn8wk02wTjae3eDMO

-benoit

Re: sending head of a view result in one chunk

Posted by Brian Candler <B....@pobox.com>.
On Wed, Jul 29, 2009 at 08:30:33PM +0200, Benoit Chesneau wrote:
> Following discussion on irc  I post here my problem. I am currently
> implementing a feature allowing me to parse the view while it's coming
> over http.  Using chunks allow me to parse each line easily. It
> currently work but currently first line of view is sent with the
> header. It would be better imo to send the header and the first line
> in different chunks, so It isn't needed to split the result. What do
> you think about it ?

Are you talking about HTTP chunking? I think it's an extremely bad idea to
rely on HTTP chunk boundaries to have significance in the sub-parts of the
body. Maybe CouchDB could generate chunks like that, but it could all be
lost by any intermediate proxy.

For parsing views in a streaming manner, CouchDB inserts a newline after
each row. This is a frig, but at least it's a portable frig. CouchRest
handles this quite happily. The headers and body are separated by \r\n\r\n
of course, and there's not much you can do about that.

Or do you mean sending a newline after the opening part of the JSON doc?
This is already done, as far as I can see.

$ curl http://127.0.0.1:5984/testdb/_all_docs
{"total_rows":1,"offset":0,"rows":[
{"id":"12345","key":"12345","value":{"rev":"1-171352454"}}
]}

I may have misunderstood you completely though.

Regards,

Brian.