couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject fabric commit: updated refs/heads/master to 1b3c795
Date Tue, 08 Jul 2014 10:58:21 GMT
Repository: couchdb-fabric
Updated Branches:
  refs/heads/master cc80c1e99 -> 1b3c7958c


Fix skip and limit values

When clustering, we must start with a `skip` of 0 to the individual
shards as we cannot know, a priori, what the correct value of `skip` is
for each shard. Instead, we start from zero and discard the first
`skip` rows. Similarly, we must boost the `limit` value by the value
of `skip`.


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

Branch: refs/heads/master
Commit: 1b3c7958c9cb55cc4376f25c401d7df5742a3480
Parents: cc80c1e
Author: Robert Newson <rnewson@apache.org>
Authored: Tue Jul 8 11:51:53 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 8 11:57:37 2014 +0100

----------------------------------------------------------------------
 src/fabric_rpc.erl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/1b3c7958/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index cd68d35..4781fb3 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -53,16 +53,22 @@ all_docs(DbName, Options, #mrargs{keys=undefined} = Args) ->
     VAcc0 = #vacc{db=Db},
     couch_mrview:query_all_docs(Db, Args, fun view_cb/2, VAcc0).
 
-map_view(DbName, DDoc, ViewName, Args) ->
+map_view(DbName, DDoc, ViewName, Args0) ->
+    Args = fix_skip_and_limit(Args0),
     {ok, Db} = get_or_create_db(DbName, []),
     VAcc0 = #vacc{db=Db},
     couch_mrview:query_view(Db, DDoc, ViewName, Args, fun view_cb/2, VAcc0).
 
-reduce_view(DbName, DDoc, ViewName, Args) ->
+reduce_view(DbName, DDoc, ViewName, Args0) ->
+    Args = fix_skip_and_limit(Args0),
     {ok, Db} = get_or_create_db(DbName, []),
     VAcc0 = #vacc{db=Db},
     couch_mrview:query_view(Db, DDoc, ViewName, Args, fun reduce_cb/2, VAcc0).
 
+fix_skip_and_limit(Args) ->
+    #mrargs{skip=Skip, limit=Limit}=Args,
+    Args#mrargs{skip=0, limit=Skip+Limit}.
+
 create_db(DbName) ->
     rexi:reply(case couch_server:create(DbName, []) of
     {ok, _} ->


Mime
View raw message