diff options
author | Damien F. Katz <damien@apache.org> | 2009-05-06 19:11:10 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-05-06 19:11:10 +0000 |
commit | 4b5e0a20aa087dd26df644c0432627aa3e5826d4 (patch) | |
tree | 1494b164fdef4004bff44aa39edbc2f1bf60d8f3 /src/couchdb/couch_rep.erl | |
parent | 887c9b1a8b551272c3ca06906cfdc4fb901830a8 (diff) |
First cut at _changes api. Update the by_id and by_seq indexes to contain update seq numbers and pointers to bodies on disk, for use in the _changes api. This is a new file version, but the code can continue to serve the old 0.9 version without problems, though certain features in the _changes api will not be able to work. Upgrade to new file version (from 1 to 2) by compacting the file. Also fixed bugs with how the stats api tracks open databases.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@772406 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep.erl')
-rw-r--r-- | src/couchdb/couch_rep.erl | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl index f7b1e9ae..721e3071 100644 --- a/src/couchdb/couch_rep.erl +++ b/src/couchdb/couch_rep.erl @@ -605,22 +605,17 @@ enum_docs_since(Pid, DbSource, DbTarget, {StartSeq, RevsCount}) -> [] -> gen_server:call(Pid, {fin, {StartSeq, RevsCount}}, infinity); DocInfoList -> - SrcRevsList = lists:map(fun(SrcDocInfo) -> - #doc_info{id=Id, - rev=Rev, - conflict_revs=Conflicts, - deleted_conflict_revs=DelConflicts - } = SrcDocInfo, - SrcRevs = [Rev | Conflicts] ++ DelConflicts, + SrcRevsList = lists:map(fun(#doc_info{id=Id,revs=RevInfos}) -> + SrcRevs = [Rev || #rev_info{rev=Rev} <- RevInfos], {Id, SrcRevs} end, DocInfoList), {ok, MissingRevs} = get_missing_revs(DbTarget, SrcRevsList), %% do we need to check for success here? - [ gen_server:call(Pid, {replicate_doc, Info}, infinity) + [gen_server:call(Pid, {replicate_doc, Info}, infinity) || Info <- MissingRevs ], - #doc_info{update_seq=LastSeq} = lists:last(DocInfoList), + #doc_info{high_seq=LastSeq} = lists:last(DocInfoList), RevsCount2 = RevsCount + length(SrcRevsList), gen_server:cast(Pid, {increment_update_seq, LastSeq}), @@ -641,15 +636,15 @@ get_doc_info_list(#http_db{uri=DbUrl, headers=Headers}, StartSeq) -> {Results} = do_http_request(Url, get, Headers), lists:map(fun({RowInfoList}) -> {RowValueProps} = proplists:get_value(<<"value">>, RowInfoList), + Seq = proplists:get_value(<<"key">>, RowInfoList), + Revs = + [#rev_info{rev=couch_doc:parse_rev(proplists:get_value(<<"rev">>, RowValueProps)), deleted = proplists:get_value(<<"deleted">>, RowValueProps, false)} | + [#rev_info{rev=Rev,deleted=false} || Rev <- couch_doc:parse_revs(proplists:get_value(<<"conflicts">>, RowValueProps, []))] ++ + [#rev_info{rev=Rev,deleted=true} || Rev <- couch_doc:parse_revs(proplists:get_value(<<"deleted_conflicts">>, RowValueProps, []))]], #doc_info{ id=proplists:get_value(<<"id">>, RowInfoList), - rev=couch_doc:parse_rev(proplists:get_value(<<"rev">>, RowValueProps)), - update_seq = proplists:get_value(<<"key">>, RowInfoList), - conflict_revs = - couch_doc:parse_revs(proplists:get_value(<<"conflicts">>, RowValueProps, [])), - deleted_conflict_revs = - couch_doc:parse_revs(proplists:get_value(<<"deleted_conflicts">>, RowValueProps, [])), - deleted = proplists:get_value(<<"deleted">>, RowValueProps, false) + high_seq = Seq, + revs = Revs } end, proplists:get_value(<<"rows">>, Results)); get_doc_info_list(DbSource, StartSeq) -> @@ -685,6 +680,7 @@ open_doc(Db, DocId, Options) -> open_doc_revs(#http_db{uri=DbUrl, headers=Headers} = DbS, DocId, Revs0, [latest]) -> + io:format("Revs0:~p~n", [Revs0]), Revs = couch_doc:rev_to_strs(Revs0), BaseUrl = DbUrl ++ url_encode(DocId) ++ "?revs=true&latest=true", |