You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/28 14:20:54 UTC

[19/50] fabric commit: updated refs/heads/master to a71701c

Pass document id & rev rather than the whole document

This uses the ddoc_cache support for revisions. It should
reduce bandwidth overhead of copying documents around.


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

Branch: refs/heads/master
Commit: df0c3a338d256e77420157c2459c763233389de4
Parents: 1f04561
Author: Brian Mitchell <br...@cloudant.com>
Authored: Mon Oct 21 13:14:40 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Aug 1 15:33:42 2014 +0100

----------------------------------------------------------------------
 src/fabric_rpc.erl         | 14 ++++++++------
 src/fabric_util.erl        |  7 ++++++-
 src/fabric_view_map.erl    |  2 +-
 src/fabric_view_reduce.erl |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/df0c3a33/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index d61da40..cee30f2 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -64,10 +64,11 @@ all_docs(DbName, Options, #mrargs{keys=undefined} = Args0) ->
     couch_mrview:query_all_docs(Db, Args, fun view_cb/2, VAcc0).
 
 %% @equiv map_view(DbName, DDoc, ViewName, Args0, [])
-map_view(DbName, DDoc, ViewName, Args0) ->
-    map_view(DbName, DDoc, ViewName, Args0, []).
+map_view(DbName, DDocInfo, ViewName, Args0) ->
+    map_view(DbName, DDocInfo, ViewName, Args0, []).
 
-map_view(DbName, DDoc, ViewName, Args0, DbOptions) ->
+map_view(DbName, {DDocId, Rev}, ViewName, Args0, DbOptions) ->
+    {ok, DDoc} = ddoc_cache:open_doc(mem3:dbname(DbName), DDocId, Rev),
     set_io_priority(DbName, DbOptions),
     Args = fix_skip_and_limit(Args0),
     {ok, Db} = get_or_create_db(DbName, DbOptions),
@@ -75,10 +76,11 @@ map_view(DbName, DDoc, ViewName, Args0, DbOptions) ->
     couch_mrview:query_view(Db, DDoc, ViewName, Args, fun view_cb/2, VAcc0).
 
 %% @equiv reduce_view(DbName, DDoc, ViewName, Args0)
-reduce_view(DbName, DDoc, ViewName, Args0) ->
-    reduce_view(DbName, DDoc, ViewName, Args0, []).
+reduce_view(DbName, DDocInfo, ViewName, Args0) ->
+    reduce_view(DbName, DDocInfo, ViewName, Args0, []).
 
-reduce_view(DbName, DDoc, ViewName, Args0, DbOptions) ->
+reduce_view(DbName, {DDocId, Rev}, ViewName, Args0, DbOptions) ->
+    {ok, DDoc} = ddoc_cache:open_doc(mem3:dbname(DbName), DDocId, Rev),
     set_io_priority(DbName, DbOptions),
     Args = fix_skip_and_limit(Args0),
     {ok, Db} = get_or_create_db(DbName, DbOptions),

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/df0c3a33/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index 344ead7..642d7d6 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -14,10 +14,12 @@
 
 -export([submit_jobs/3, submit_jobs/4, cleanup/1, recv/4, get_db/1, get_db/2, error_info/1,
         update_counter/3, remove_ancestors/2, create_monitors/1, kv/2,
-        remove_down_workers/2]).
+        remove_down_workers/2, doc_id_and_rev/1]).
 -export([request_timeout/0, attachments_timeout/0, all_docs_timeout/0]).
 -export([stream_start/2, stream_start/4]).
 
+-compile({inline, [{doc_id_and_rev,1}]}).
+
 -include_lib("fabric/include/fabric.hrl").
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
@@ -271,3 +273,6 @@ remove_ancestors_test() ->
 %% test function
 kv(Item, Count) ->
     {make_key(Item), {Item,Count}}.
+
+doc_id_and_rev(#doc{id=DocId, revs={RevNum, [RevHash|_]}}) ->
+    {DocId, {RevNum, RevHash}}.

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/df0c3a33/src/fabric_view_map.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_map.erl b/src/fabric_view_map.erl
index d2c010a..1201daf 100644
--- a/src/fabric_view_map.erl
+++ b/src/fabric_view_map.erl
@@ -26,7 +26,7 @@ go(DbName, GroupId, View, Args, Callback, Acc0) when is_binary(GroupId) ->
 go(DbName, DDoc, View, Args, Callback, Acc) ->
     Shards = fabric_view:get_shards(DbName, Args),
     Repls = fabric_view:get_shard_replacements(DbName, Shards),
-    RPCArgs = [DDoc, View, Args],
+    RPCArgs = [fabric_util:doc_id_and_rev(DDoc), View, Args],
     StartFun = fun(Shard) ->
         hd(fabric_util:submit_jobs([Shard], fabric_rpc, map_view, RPCArgs))
     end,

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/df0c3a33/src/fabric_view_reduce.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_reduce.erl b/src/fabric_view_reduce.erl
index 67c36a3..2e0d1f2 100644
--- a/src/fabric_view_reduce.erl
+++ b/src/fabric_view_reduce.erl
@@ -25,7 +25,7 @@ go(DbName, GroupId, View, Args, Callback, Acc0, VInfo) when is_binary(GroupId) -
 
 go(DbName, DDoc, VName, Args, Callback, Acc, {red, {_, Lang, _}, _}=VInfo) ->
     RedSrc = couch_mrview_util:extract_view_reduce(VInfo),
-    RPCArgs = [DDoc, VName, Args],
+    RPCArgs = [fabric_util:doc_id_and_rev(DDoc), VName, Args],
     Shards = fabric_view:get_shards(DbName, Args),
     Repls = fabric_view:get_shard_replacements(DbName, Shards),
     StartFun = fun(Shard) ->