You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2014/10/16 11:36:16 UTC

[3/3] couch-mrview commit: updated refs/heads/master to 1a6bd40

Count mapped docs one by one

Assuming that couch_stats:increment_counter call is cheap (due to ETS
power on backend) this let us to provide more fine grained values for
mapped docs. Doing this in bulk, as it was, leads us to the situation
when counters are telling that some batch of docs get mapped while it's
what is actually happening right now or even mapping failed on the half
of the way by some reason - this is the case when stats will lie us.


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

Branch: refs/heads/master
Commit: 1a6bd404e4c68f18d95fd9be6f731e3d8782870d
Parents: 69a5957
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Oct 14 22:37:27 2014 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Oct 14 22:37:27 2014 +0400

----------------------------------------------------------------------
 src/couch_mrview_updater.erl | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/1a6bd404/src/couch_mrview_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_updater.erl b/src/couch_mrview_updater.erl
index e0b3e1e..1525a4c 100644
--- a/src/couch_mrview_updater.erl
+++ b/src/couch_mrview_updater.erl
@@ -143,14 +143,13 @@ map_docs(Parent, State0) ->
                 ({Id, Seq, deleted}, {SeqAcc, Results}) ->
                     {erlang:max(Seq, SeqAcc), [{Id, []} | Results]};
                 ({Id, Seq, Doc}, {SeqAcc, Results}) ->
+                    couch_stats:increment_counter([couchdb, mrview, map_docs],
+                                                  1),
                     {ok, Res} = couch_query_servers:map_doc_raw(QServer, Doc),
                     {erlang:max(Seq, SeqAcc), [{Id, Res} | Results]}
             end,
             FoldFun = fun(Docs, Acc) ->
-                LenDocs = length(Docs),
-                couch_stats:increment_counter([couchdb, mrview, map_docs],
-                                              LenDocs),
-                update_task(LenDocs),
+                update_task(length(Docs)),
                 lists:foldl(DocFun, Acc, Docs)
             end,
             Results = lists:foldl(FoldFun, {0, []}, Dequeued),