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 2014/03/26 19:16:37 UTC

[1/2] chttpd commit: updated refs/heads/1993-bigcouch-couch-mrview to a93a9ab

Repository: couchdb-chttpd
Updated Branches:
  refs/heads/1993-bigcouch-couch-mrview 5ba4717a7 -> a93a9ab18


Remove obsolete chttpd_view:get_reduce_type


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/ce5569cd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/ce5569cd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/ce5569cd

Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: ce5569cd6094794dad7fbe5328fdba9483aef580
Parents: 5ba4717
Author: Russell Branca <ch...@gmail.com>
Authored: Wed Mar 26 09:55:29 2014 -0700
Committer: Russell Branca <ch...@gmail.com>
Committed: Wed Mar 26 09:55:29 2014 -0700

----------------------------------------------------------------------
 src/chttpd_view.erl | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/ce5569cd/src/chttpd_view.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl
index eedf266..471c380 100644
--- a/src/chttpd_view.erl
+++ b/src/chttpd_view.erl
@@ -14,7 +14,7 @@
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch_mrview/include/couch_mrview.hrl").
 
--export([handle_view_req/3, handle_temp_view_req/2, get_reduce_type/1]).
+-export([handle_view_req/3, handle_temp_view_req/2]).
 
 multi_query_view(Req, Db, DDoc, ViewName, Queries) ->
     Args0 = couch_mrview_http:parse_params(Req, undefined),
@@ -97,14 +97,3 @@ handle_view_req(Req, _Db, _DDoc) ->
 handle_temp_view_req(Req, _Db) ->
     Msg = <<"Temporary views are not supported in CouchDB">>,
     chttpd:send_error(Req, 403, forbidden, Msg).
-
-%% TODO: remove this once chttpd_show has been updated to use couch_mrview
-get_reduce_type(Req) ->
-    case chttpd:qs_value(Req, "reduce", "true") of
-    "true" ->
-        true;
-    "false" ->
-        false;
-    _Error ->
-        throw({bad_request, "`reduce` qs param must be `true` or `false`"})
-    end.


[2/2] chttpd commit: updated refs/heads/1993-bigcouch-couch-mrview to a93a9ab

Posted by ch...@apache.org.
Fix clustered _all_dbs


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/a93a9ab1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/a93a9ab1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/a93a9ab1

Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: a93a9ab183fceb911a4e084c6526b4b657697cce
Parents: ce5569c
Author: Russell Branca <ch...@gmail.com>
Authored: Wed Mar 26 11:16:34 2014 -0700
Committer: Russell Branca <ch...@gmail.com>
Committed: Wed Mar 26 11:16:34 2014 -0700

----------------------------------------------------------------------
 src/chttpd_misc.erl | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/a93a9ab1/src/chttpd_misc.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_misc.erl b/src/chttpd_misc.erl
index 8c5f50e..01bddf7 100644
--- a/src/chttpd_misc.erl
+++ b/src/chttpd_misc.erl
@@ -89,34 +89,42 @@ handle_sleep_req(Req) ->
     send_method_not_allowed(Req, "GET,HEAD").
 
 handle_all_dbs_req(#httpd{method='GET'}=Req) ->
+    Args = couch_mrview_http:parse_params(Req, undefined),
     ShardDbName = config:get("mem3", "shard_db", "dbs"),
     %% shard_db is not sharded but mem3:shards treats it as an edge case
     %% so it can be pushed thru fabric
     {ok, Info} = fabric:get_db_info(ShardDbName),
     Etag = couch_httpd:make_etag({Info}),
-    chttpd:etag_respond(Req, Etag, fun() ->
+    {ok, Resp} = chttpd:etag_respond(Req, Etag, fun() ->
         {ok, Resp} = chttpd:start_delayed_json_response(Req, 200, [{"Etag",Etag}]),
-        fabric:all_docs(ShardDbName, fun all_dbs_callback/2,
-            {nil, Resp}, #mrargs{})
-    end);
+        VAcc = #vacc{req=Req,resp=Resp},
+        fabric:all_docs(ShardDbName, fun all_dbs_callback/2, VAcc, Args)
+    end),
+    case is_record(Resp, vacc) of
+        true -> {ok, Resp#vacc.resp};
+        _ -> {ok, Resp}
+    end;
 handle_all_dbs_req(Req) ->
     send_method_not_allowed(Req, "GET,HEAD").
 
-all_dbs_callback({total_and_offset, _Total, _Offset}, {_, Resp}) ->
-    {ok, Resp1} = chttpd:send_delayed_chunk(Resp, "["),
-    {ok, {"", Resp1}};
-all_dbs_callback({row, {Row}}, {Prepend, Resp}) ->
+all_dbs_callback({meta, _Meta}, #vacc{resp=Resp0}=Acc) ->
+    {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, "["),
+    {ok, Acc#vacc{resp=Resp1}};
+all_dbs_callback({row, Row}, #vacc{resp=Resp0}=Acc) ->
+    Prepend = couch_mrview_http:prepend_val(Acc),
     case couch_util:get_value(id, Row) of <<"_design", _/binary>> ->
-        {ok, {Prepend, Resp}};
+        {ok, Acc};
     DbName ->
-        {ok, Resp1} = chttpd:send_delayed_chunk(Resp, [Prepend, ?JSON_ENCODE(DbName)]),
-        {ok, {",", Resp1}}
+        {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, [Prepend, ?JSON_ENCODE(DbName)]),
+        {ok, Acc#vacc{prepend=",", resp=Resp1}}
     end;
-all_dbs_callback(complete, {_, Resp}) ->
-    {ok, Resp1} = chttpd:send_delayed_chunk(Resp, "]"),
-    chttpd:end_delayed_json_response(Resp1);
-all_dbs_callback({error, Reason}, {_, Resp}) ->
-    chttpd:send_delayed_error(Resp, Reason).
+all_dbs_callback(complete, #vacc{resp=Resp0}=Acc) ->
+    {ok, Resp1} = chttpd:send_delayed_chunk(Resp0, "]"),
+    {ok, Resp2} = chttpd:end_delayed_json_response(Resp1),
+    {ok, Acc#vacc{resp=Resp2}};
+all_dbs_callback({error, Reason}, #vacc{resp=Resp0}=Acc) ->
+    {ok, Resp1} = chttpd:send_delayed_error(Resp0, Reason),
+    {ok, Acc#vacc{resp=Resp1}}.
 
 handle_task_status_req(#httpd{method='GET'}=Req) ->
     {Replies, _BadNodes} = gen_server:multi_call(couch_task_status, all),