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 37bcda9
Date Tue, 21 Jun 2016 20:14:45 GMT
Repository: couchdb-fabric
Updated Branches:
  refs/heads/master 18e6fd852 -> 37bcda9c3


Support update_seq=true in _all_docs


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

Branch: refs/heads/master
Commit: 37bcda9c336bd4d8064a498f84122feeb74abf44
Parents: 18e6fd8
Author: Robert Newson <rnewson@apache.org>
Authored: Tue Jun 21 21:14:07 2016 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jun 21 21:14:07 2016 +0100

----------------------------------------------------------------------
 src/fabric_view_all_docs.erl | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/37bcda9c/src/fabric_view_all_docs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index 52c0a77..949cc30 100644
--- a/src/fabric_view_all_docs.erl
+++ b/src/fabric_view_all_docs.erl
@@ -93,7 +93,7 @@ go(DbName, _Options, QueryArgs, Callback, Acc0) ->
     end.
 
 go(DbName, _Options, Workers, QueryArgs, Callback, Acc0) ->
-    #mrargs{limit = Limit, skip = Skip} = QueryArgs,
+    #mrargs{limit = Limit, skip = Skip, update_seq = UpdateSeq} = QueryArgs,
     State = #collector{
         db_name = DbName,
         query_args = QueryArgs,
@@ -101,7 +101,8 @@ go(DbName, _Options, Workers, QueryArgs, Callback, Acc0) ->
         counters = fabric_dict:init(Workers, 0),
         skip = Skip,
         limit = Limit,
-        user_acc = Acc0
+        user_acc = Acc0,
+        update_seq = case UpdateSeq of true -> []; false -> nil end
     },
     case rexi_utils:recv(Workers, #shard.ref, fun handle_message/3,
         State, infinity, 5000) of
@@ -122,12 +123,14 @@ handle_message({rexi_EXIT, Reason}, Worker, State) ->
 handle_message({meta, Meta0}, {Worker, From}, State) ->
     Tot = couch_util:get_value(total, Meta0, 0),
     Off = couch_util:get_value(offset, Meta0, 0),
+    Seq = couch_util:get_value(update_seq, Meta0, 0),
     #collector{
         callback = Callback,
         counters = Counters0,
         total_rows = Total0,
         offset = Offset0,
-        user_acc = AccIn
+        user_acc = AccIn,
+        update_seq = UpdateSeq0
     } = State,
     % Assert that we don't have other messages from this
     % worker when the total_and_offset message arrives.
@@ -136,22 +139,34 @@ handle_message({meta, Meta0}, {Worker, From}, State) ->
     Counters1 = fabric_dict:update_counter(Worker, 1, Counters0),
     Total = Total0 + Tot,
     Offset = Offset0 + Off,
+    UpdateSeq = case UpdateSeq0 of
+        nil -> nil;
+        _   -> [{Worker, Seq} | UpdateSeq0]
+    end,
     case fabric_dict:any(0, Counters1) of
     true ->
         {ok, State#collector{
             counters = Counters1,
             total_rows = Total,
+            update_seq = UpdateSeq,
             offset = Offset
         }};
     false ->
         FinalOffset = erlang:min(Total, Offset+State#collector.skip),
-        Meta = [{total, Total}, {offset, FinalOffset}],
+        Meta = [{total, Total}, {offset, FinalOffset}] ++
+            case UpdateSeq of
+                nil ->
+                    [];
+                _ ->
+                    [{update_seq, fabric_view_changes:pack_seqs(UpdateSeq)}]
+            end,
         {Go, Acc} = Callback({meta, Meta}, AccIn),
         {Go, State#collector{
             counters = fabric_dict:decrement_all(Counters1),
             total_rows = Total,
             offset = FinalOffset,
-            user_acc = Acc
+            user_acc = Acc,
+            update_seq = UpdateSeq0
         }}
     end;
 


Mime
View raw message