You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2016/07/15 00:22:32 UTC

[2/2] couch-mrview commit: updated refs/heads/fix-unsorted-views to 22e0f92

WIP: add support for sorted=false views

With sorted=false views, we get view rows prior to the meta row. So
let's just save the metadata until the end and tack on total_rows and
the other fields as we finish the response.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/22e0f927
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/22e0f927
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/22e0f927

Branch: refs/heads/fix-unsorted-views
Commit: 22e0f9273efaa00d5bbd4c0425ab688bbb125ca3
Parents: 734d1da
Author: Russell Branca <ch...@apache.org>
Authored: Fri Jul 15 00:12:45 2016 +0000
Committer: Russell Branca <ch...@apache.org>
Committed: Fri Jul 15 00:12:45 2016 +0000

----------------------------------------------------------------------
 include/couch_mrview.hrl  | 1 +
 src/couch_mrview_http.erl | 8 ++++++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/22e0f927/include/couch_mrview.hrl
----------------------------------------------------------------------
diff --git a/include/couch_mrview.hrl b/include/couch_mrview.hrl
index 7dc7190..ed804b0 100644
--- a/include/couch_mrview.hrl
+++ b/include/couch_mrview.hrl
@@ -95,6 +95,7 @@
     resp,
     prepend,
     etag,
+    meta,
     should_close = false,
     buffer = [],
     bufsize = 0,

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/22e0f927/src/couch_mrview_http.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_http.erl b/src/couch_mrview_http.erl
index 3f29cac..87022d9 100644
--- a/src/couch_mrview_http.erl
+++ b/src/couch_mrview_http.erl
@@ -339,6 +339,14 @@ view_cb({meta, Meta}, #vacc{resp=undefined}=Acc) ->
     Headers = [],
     {ok, Resp} = chttpd:start_delayed_json_response(Acc#vacc.req, 200, Headers),
     view_cb({meta, Meta}, Acc#vacc{resp=Resp, should_close=true});
+view_cb({row, Row}, #vacc{resp=undefined}=Acc) ->
+    % sorted=false view start
+    Headers = [],
+    {ok, Resp} = chttpd:start_delayed_json_response(Acc#vacc.req, 200, Headers, "{\"rows\":[\r\n"),
+    view_cb({row, Row}, Acc#vacc{resp=Resp, should_close=true});
+view_cb({unsorted_meta, Meta}, #vacc{}=Acc) ->
+    %% TODO:: append total_rows upon view completion
+    {ok, Acc#vacc{meta=Meta}};
 view_cb({meta, Meta}, #vacc{}=Acc) ->
     % Sending metadata
     Parts = case couch_util:get_value(total, Meta) of