couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [2/2] couch-mrview commit: updated refs/heads/fix-unsorted-views to 22e0f92
Date Fri, 15 Jul 2016 00:22:32 GMT
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 <chewbranca@apache.org>
Authored: Fri Jul 15 00:12:45 2016 +0000
Committer: Russell Branca <chewbranca@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


Mime
View raw message