couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [3/9] couch-mrview commit: updated refs/heads/master to 065dc26
Date Fri, 30 Jan 2015 18:10:56 GMT
Add couch_mrview_http:handle_local_docs_req

COUCHDB-1145


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/e935477d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/e935477d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/e935477d

Branch: refs/heads/master
Commit: e935477d553d2c392314b728b08500758f2a3e1c
Parents: 2212d28
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Tue Dec 16 12:41:05 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed Dec 31 10:47:04 2014 -0800

----------------------------------------------------------------------
 src/couch_mrview.erl      | 18 +++++++++++++++++-
 src/couch_mrview_http.erl |  9 +++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/e935477d/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index 26d1cb2..f4ba6e1 100644
--- a/src/couch_mrview.erl
+++ b/src/couch_mrview.erl
@@ -409,9 +409,25 @@ map_fold({{Key, Id}, Val}, _Offset, Acc) ->
         doc_info=undefined,
         user_acc=UAcc1,
         last_go=Go
+    }};
+map_fold({<<"_local/",_/binary>> = DocId, {Rev0, _Body}}, _Offset, #mracc{} =
Acc) ->
+    #mracc{
+        limit=Limit,
+        callback=Callback,
+        user_acc=UAcc0
+    } = Acc,
+    Rev = {0, list_to_binary(integer_to_list(Rev0))},
+    Value = {[{rev, couch_doc:rev_to_str(Rev)}]},
+    Row = [{id, DocId}, {key, DocId}, {value, Value}],
+    {Go, UAcc1} = Callback({row, Row}, UAcc0),
+    {Go, Acc#mracc{
+        limit=Limit-1,
+        reduce_fun=undefined,
+        doc_info=undefined,
+        user_acc=UAcc1,
+        last_go=Go
     }}.
 
-
 red_fold(Db, {_Nth, _Lang, View}=RedView, Args, Callback, UAcc) ->
     Acc = #mracc{
         db=Db,

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/e935477d/src/couch_mrview_http.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_http.erl b/src/couch_mrview_http.erl
index 527c89e..70104e8 100644
--- a/src/couch_mrview_http.erl
+++ b/src/couch_mrview_http.erl
@@ -14,6 +14,7 @@
 
 -export([
     handle_all_docs_req/2,
+    handle_local_docs_req/2,
     handle_view_changes_req/3,
     handle_reindex_req/3,
     handle_view_req/3,
@@ -48,6 +49,14 @@ handle_all_docs_req(#httpd{method='POST'}=Req, Db) ->
 handle_all_docs_req(Req, _Db) ->
     couch_httpd:send_method_not_allowed(Req, "GET,POST,HEAD").
 
+handle_local_docs_req(#httpd{method='GET'}=Req, Db) ->
+    all_docs_req(Req, Db, undefined, <<"_local">>);
+handle_local_docs_req(#httpd{method='POST'}=Req, Db) ->
+    Keys = couch_mrview_util:get_view_keys(couch_httpd:json_body_obj(Req)),
+    all_docs_req(Req, Db, Keys, <<"_local">>);
+handle_local_docs_req(Req, _Db) ->
+    couch_httpd:send_method_not_allowed(Req, "GET,POST,HEAD").
+
 handle_reindex_req(#httpd{method='POST',
                           path_parts=[_, _, DName,<<"_reindex">>]}=Req,
                    Db, _DDoc) ->


Mime
View raw message