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 dc5cca8
Date Sun, 17 Apr 2016 18:43:18 GMT
Repository: couchdb-fabric
Updated Branches:
  refs/heads/master 1be5506e3 -> dc5cca804


Honor update_seq=true for map view requests

COUCHDB-2849


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

Branch: refs/heads/master
Commit: dc5cca804132266edec7a62cb2ca6b36cfadab27
Parents: 1be5506
Author: Robert Newson <rnewson@apache.org>
Authored: Sun Apr 17 19:18:16 2016 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Sun Apr 17 19:18:16 2016 +0100

----------------------------------------------------------------------
 include/fabric.hrl      |  3 ++-
 src/fabric_view_map.erl | 22 ++++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/dc5cca80/include/fabric.hrl
----------------------------------------------------------------------
diff --git a/include/fabric.hrl b/include/fabric.hrl
index 29fc1ff..be1d639 100644
--- a/include/fabric.hrl
+++ b/include/fabric.hrl
@@ -30,7 +30,8 @@
     collation,
     lang,
     sorted,
-    user_acc
+    user_acc,
+    update_seq
 }).
 
 -record(stream_acc, {

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/dc5cca80/src/fabric_view_map.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_map.erl b/src/fabric_view_map.erl
index 7e27637..a71e01a 100644
--- a/src/fabric_view_map.erl
+++ b/src/fabric_view_map.erl
@@ -58,7 +58,7 @@ go(DbName, DDoc, View, Args, Callback, Acc, VInfo) ->
     end.
 
 go(DbName, Workers, {map, View, _}, Args, Callback, Acc0) ->
-    #mrargs{limit = Limit, skip = Skip, keys = Keys} = Args,
+    #mrargs{limit = Limit, skip = Skip, keys = Keys, update_seq=UpdateSeq} = Args,
     Collation = couch_util:get_value(<<"collation">>, View#mrview.options),
     State = #collector{
         db_name=DbName,
@@ -70,7 +70,8 @@ go(DbName, Workers, {map, View, _}, Args, Callback, Acc0) ->
         keys = fabric_view:keydict(Keys),
         sorted = Args#mrargs.sorted,
         collation = Collation,
-        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, 1000 * 60 * 60) of
@@ -91,12 +92,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.
@@ -105,16 +108,27 @@ 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),


Mime
View raw message