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/02/12 23:56:17 UTC

fabric commit: updated refs/heads/1993-bigcouch-couch-mrview to 32d3739

Updated Branches:
  refs/heads/1993-bigcouch-couch-mrview 1e41d8012 -> 32d373975


Properly use couch_mrview:query_all_docs in fabric_rpc


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

Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: 32d3739753c21cd94f70cdf7d0973bb96d38f893
Parents: 1e41d80
Author: Russell Branca <ch...@gmail.com>
Authored: Wed Feb 12 14:56:24 2014 -0800
Committer: Russell Branca <ch...@gmail.com>
Committed: Wed Feb 12 14:56:24 2014 -0800

----------------------------------------------------------------------
 src/fabric_rpc.erl | 39 ++++++---------------------------------
 1 file changed, 6 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/32d37397/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 074beb2..bc3112d 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -39,38 +39,6 @@
 %% rpc endpoints
 %%  call to with_db will supply your M:F with a #db{} and then remaining args
 
-all_docs(DbName, #mrargs{keys=undefined} = QueryArgs) ->
-    {ok, Db} = get_or_create_db(DbName, []),
-    #mrargs{
-        start_key = StartKey,
-        start_key_docid = StartDocId,
-        end_key = EndKey,
-        end_key_docid = EndDocId,
-        limit = Limit,
-        skip = Skip,
-        include_docs = IncludeDocs,
-        direction = Dir,
-        inclusive_end = Inclusive,
-        extra = Extra
-    } = QueryArgs,
-    set_io_priority(DbName, Extra),
-    {ok, Total} = couch_db:get_doc_count(Db),
-    Acc0 = #view_acc{
-        db = Db,
-        include_docs = IncludeDocs,
-        conflicts = proplists:get_value(conflicts, Extra, false),
-        limit = Limit+Skip,
-        total_rows = Total
-    },
-    EndKeyType = if Inclusive -> end_key; true -> end_key_gt end,
-    Options = [
-        {dir, Dir},
-        {start_key, if is_binary(StartKey) -> StartKey; true -> StartDocId end},
-        {EndKeyType, if is_binary(EndKey) -> EndKey; true -> EndDocId end}
-    ],
-    {ok, _, Acc} = couch_db:enum_docs(Db, fun view_fold/3, Acc0, Options),
-    final_response(Total, Acc#view_acc.offset).
-
 changes(DbName, #changes_args{} = Args, StartSeq) ->
     changes(DbName, [Args], StartSeq);
 changes(DbName, Options, StartSeq) ->
@@ -92,6 +60,11 @@ changes(DbName, Options, StartSeq) ->
         rexi:reply(Error)
     end.
 
+all_docs(DbName, #mrargs{keys=undefined} = Args) ->
+    {ok, Db} = get_or_create_db(DbName, []),
+    VAcc0 = #vacc{db=Db},
+    couch_mrview:query_all_docs(Db, Args, fun view_cb/2, VAcc0).
+
 map_view(DbName, DDoc, ViewName, Args) ->
     {ok, Db} = get_or_create_db(DbName, []),
     VAcc0 = #vacc{db=Db},
@@ -250,7 +223,7 @@ view_cb({row, Row}, Acc) ->
     ViewRow = #view_row{
         id = couch_util:get_value(id, Row),
         key = couch_util:get_value(key, Row),
-        value = couch_util:get_value(val, Row),
+        value = couch_util:get_value(value, Row),
         doc = couch_util:get_value(doc, Row)
     },
     case rexi:stream(ViewRow) of