diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2009-08-24 17:34:48 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2009-08-24 17:34:48 +0000 |
commit | 64d37bfd07c5e62561a38570f2cd3983567d3967 (patch) | |
tree | 5f6176962b594bc861654d7f5695b3e979d0f89d /src/couchdb/couch_rep_missing_revs.erl | |
parent | e1b6dd15d993a3f424747ef5fc89ffa95a961613 (diff) |
more precise and accurate calculation of replication progress
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@807308 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep_missing_revs.erl')
-rw-r--r-- | src/couchdb/couch_rep_missing_revs.erl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/couchdb/couch_rep_missing_revs.erl b/src/couchdb/couch_rep_missing_revs.erl index 7e1dc16a..59ab30ec 100644 --- a/src/couchdb/couch_rep_missing_revs.erl +++ b/src/couchdb/couch_rep_missing_revs.erl @@ -148,6 +148,7 @@ get_missing_revs(#http_db{}=Target, Changes) -> Transform = fun({[{<<"seq">>,_}, {<<"id">>,Id}, {<<"changes">>,C}]}) -> {Id, [couch_doc:rev_to_str(R) || {[{<<"rev">>, R}]} <- C]} end, IdRevsList = [Transform(Change) || Change <- Changes], + SeqDict = changes_dictionary(Changes), {[{<<"seq">>, HighSeq}, _, _]} = lists:last(Changes), Request = Target#http_db{ resource = "_missing_revs", @@ -156,16 +157,23 @@ get_missing_revs(#http_db{}=Target, Changes) -> }, {Resp} = couch_rep_httpc:request(Request), {MissingRevs} = proplists:get_value(<<"missing_revs">>, Resp), - X = [{Id, couch_doc:parse_revs(RevStrs)} || {Id,RevStrs} <- MissingRevs], + X = [{Id, dict:fetch(Id, SeqDict), couch_doc:parse_revs(RevStrs)} || + {Id,RevStrs} <- MissingRevs], {HighSeq, X}; get_missing_revs(Target, Changes) -> Transform = fun({[{<<"seq">>,_}, {<<"id">>,Id}, {<<"changes">>,C}]}) -> {Id, [R || {[{<<"rev">>, R}]} <- C]} end, IdRevsList = [Transform(Change) || Change <- Changes], + SeqDict = changes_dictionary(Changes), {[{<<"seq">>, HighSeq}, _, _]} = lists:last(Changes), {ok, Results} = couch_db:get_missing_revs(Target, IdRevsList), - {HighSeq, Results}. + {HighSeq, [{Id, dict:fetch(Id, SeqDict), Revs} || {Id, Revs} <- Results]}. + +changes_dictionary(ChangeList) -> + KVs = [{proplists:get_value(<<"id">>,C), proplists:get_value(<<"seq">>,C)} + || {C} <- ChangeList], + dict:from_list(KVs). %% save a checkpoint if no revs are missing on target so we don't %% rescan metadata unnecessarily |