Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 76682200B17 for ; Tue, 21 Jun 2016 22:14:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 74F11160A4F; Tue, 21 Jun 2016 20:14:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BC26D160A07 for ; Tue, 21 Jun 2016 22:14:46 +0200 (CEST) Received: (qmail 75388 invoked by uid 500); 21 Jun 2016 20:14:45 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 75377 invoked by uid 99); 21 Jun 2016 20:14:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2016 20:14:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B15E3E020A; Tue, 21 Jun 2016 20:14:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Message-Id: <79b2bd791072465f82ce2121047bcb29@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: fabric commit: updated refs/heads/master to 37bcda9 Date: Tue, 21 Jun 2016 20:14:45 +0000 (UTC) archived-at: Tue, 21 Jun 2016 20:14:47 -0000 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 Authored: Tue Jun 21 21:14:07 2016 +0100 Committer: Robert Newson 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;