You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2010/10/02 23:41:31 UTC
svn commit: r1003894 -
/couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl
Author: fdmanana
Date: Sat Oct 2 21:41:31 2010
New Revision: 1003894
URL: http://svn.apache.org/viewvc?rev=1003894&view=rev
Log:
New replicator: avoid sending useless messages to a gen_server replicator.
Modified:
couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl
Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl?rev=1003894&r1=1003893&r2=1003894&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator_rev_finders.erl Sat Oct 2 21:41:31 2010
@@ -69,9 +69,7 @@ missing_revs_finder_loop(FinderId, Cp, T
#doc_info{id=Id, revs=RevsInfo, high_seq=Seq} <- DocInfos]),
NonMissingIdRevsSeqDict = remove_missing(IdRevsSeqDict, Missing),
% signal the completion of these that aren't missing
- Cp ! {seq_changes_done,
- [{Seq, length(Revs)} ||
- {_Id, {Revs, Seq}} <- dict:to_list(NonMissingIdRevsSeqDict)]},
+ report_non_missing(NonMissingIdRevsSeqDict, Cp),
% Expand out each docs and seq into it's own work item
MissingCount = lists:foldl(
@@ -81,11 +79,28 @@ missing_revs_finder_loop(FinderId, Cp, T
ok = couch_work_queue:queue(RevsQueue, {Id, Revs, PAs, Seq}),
Count + length(Revs)
end, 0, Missing),
- Cp ! {add_stat, {#rep_stats.missing_found, MissingCount}},
+ maybe_add_stat(MissingCount, #rep_stats.missing_found, Cp),
missing_revs_finder_loop(FinderId, Cp, Target, ChangesQueue, RevsQueue)
end.
+report_non_missing(RevsDict, Cp) ->
+ case dict:size(RevsDict) of
+ 0 ->
+ ok;
+ N when N > 0 ->
+ Cp ! {seq_changes_done,
+ [{Seq, length(Revs)} ||
+ {_Id, {Revs, Seq}} <- dict:to_list(RevsDict)]}
+ end.
+
+
+maybe_add_stat(0, _StatPos, _Cp) ->
+ ok;
+maybe_add_stat(Value, StatPos, Cp) ->
+ Cp ! {add_stat, {StatPos, Value}}.
+
+
remove_missing(IdRevsSeqDict, []) ->
IdRevsSeqDict;