diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2011-02-10 08:11:01 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2011-02-10 08:11:01 +0000 |
commit | 4158b51580cb27cbe143384f1ca41ac18c9ea0cb (patch) | |
tree | d41d82e6f7c390a42aa3052dfbb5ff0c7888b1b0 /src/couchdb/couch_changes.erl | |
parent | 00d2709afbff6f402d91f5d1dc3e5a5075685c49 (diff) |
Merged revision 1069262 from trunk
More efficient _changes?include_docs=true and _all_docs?include_docs=true
Closes COUCHDB-1061
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1069264 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_changes.erl')
-rw-r--r-- | src/couchdb/couch_changes.erl | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl index 838f7e66..6baaf7ec 100644 --- a/src/couchdb/couch_changes.erl +++ b/src/couchdb/couch_changes.erl @@ -261,8 +261,7 @@ end_sending_changes(Callback, UserAcc, EndSeq, ResponseType) -> changes_enumerator(DocInfo, {Db, _, _, FilterFun, Callback, UserAcc, "continuous", Limit, IncludeDocs}) -> - #doc_info{id=Id, high_seq=Seq, - revs=[#rev_info{deleted=Del,rev=Rev}|_]} = DocInfo, + #doc_info{high_seq = Seq} = DocInfo, Results0 = FilterFun(DocInfo), Results = [Result || Result <- Results0, Result /= null], Go = if Limit =< 1 -> stop; true -> ok end, @@ -272,7 +271,7 @@ changes_enumerator(DocInfo, {Db, _, _, FilterFun, Callback, UserAcc, IncludeDocs} }; _ -> - ChangesRow = changes_row(Db, Seq, Id, Del, Results, Rev, IncludeDocs), + ChangesRow = changes_row(Db, Results, DocInfo, IncludeDocs), UserAcc2 = Callback({change, ChangesRow, <<>>}, "continuous", UserAcc), {Go, {Db, Seq, nil, FilterFun, Callback, UserAcc2, "continuous", Limit - 1, IncludeDocs} @@ -281,8 +280,7 @@ changes_enumerator(DocInfo, {Db, _, _, FilterFun, Callback, UserAcc, changes_enumerator(DocInfo, {Db, _, Prepend, FilterFun, Callback, UserAcc, ResponseType, Limit, IncludeDocs}) -> - #doc_info{id=Id, high_seq=Seq, revs=[#rev_info{deleted=Del,rev=Rev}|_]} - = DocInfo, + #doc_info{high_seq = Seq} = DocInfo, Results0 = FilterFun(DocInfo), Results = [Result || Result <- Results0, Result /= null], Go = if (Limit =< 1) andalso Results =/= [] -> stop; true -> ok end, @@ -292,7 +290,7 @@ changes_enumerator(DocInfo, {Db, _, Prepend, FilterFun, Callback, UserAcc, Limit, IncludeDocs} }; _ -> - ChangesRow = changes_row(Db, Seq, Id, Del, Results, Rev, IncludeDocs), + ChangesRow = changes_row(Db, Results, DocInfo, IncludeDocs), UserAcc2 = Callback({change, ChangesRow, Prepend}, ResponseType, UserAcc), {Go, {Db, Seq, <<",\n">>, FilterFun, Callback, UserAcc2, ResponseType, Limit - 1, IncludeDocs} @@ -300,12 +298,15 @@ changes_enumerator(DocInfo, {Db, _, Prepend, FilterFun, Callback, UserAcc, end. -changes_row(Db, Seq, Id, Del, Results, Rev, true) -> +changes_row(Db, Results, DocInfo, IncludeDoc) -> + #doc_info{ + id = Id, high_seq = Seq, revs = [#rev_info{deleted = Del} | _] + } = DocInfo, {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Results}] ++ - deleted_item(Del) ++ couch_httpd_view:doc_member(Db, {Id, Rev})}; -changes_row(_, Seq, Id, Del, Results, _, false) -> - {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"changes">>, Results}] ++ - deleted_item(Del)}. + deleted_item(Del) ++ case IncludeDoc of + true -> couch_httpd_view:doc_member(Db, DocInfo); + false -> [] + end}. deleted_item(true) -> [{<<"deleted">>, true}]; deleted_item(_) -> []. |