diff options
author | Garren Smith <garren.smith@gmail.com> | 2020-04-06 12:04:56 +0200 |
---|---|---|
committer | garren smith <garren.smith@gmail.com> | 2020-04-23 19:24:43 +0200 |
commit | 5efcbfc3ca114696273f56b1c98876c95e63bda7 (patch) | |
tree | 0ddd75805d43401d311bbdea4ddf4843cda7ae69 /src/chttpd/src/chttpd_db.erl | |
parent | f522b880b68109feb5960d6d8244ac034990059e (diff) | |
download | couchdb-5efcbfc3ca114696273f56b1c98876c95e63bda7.tar.gz |
Add fold_docs for DocId list
Adds a fold_docs function that will do a parallel fetch for the supplied
Doc Ids. This is used for _all_docs?keys=["id1", "id2"].
This uses a queue for fetching the revs and another queue for fetching
the doc bodies. These queues will be drained if the future queue gets
to large.
Diffstat (limited to 'src/chttpd/src/chttpd_db.erl')
-rw-r--r-- | src/chttpd/src/chttpd_db.erl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl index 8cfcfecaa..078009590 100644 --- a/src/chttpd/src/chttpd_db.erl +++ b/src/chttpd/src/chttpd_db.erl @@ -902,9 +902,10 @@ send_all_docs_keys(Db, #mrargs{} = Args, VAcc0) -> _ -> Args#mrargs.doc_options end, IncludeDocs = Args#mrargs.include_docs, - lists:foldl(fun(DocId, Acc) -> - OpenOpts = [deleted | DocOpts], - Row0 = case fabric2_db:open_doc(Db, DocId, OpenOpts) of + OpenOpts = [deleted | DocOpts], + + CB = fun(DocId, Doc, Acc) -> + Row0 = case Doc of {not_found, missing} -> #view_row{key = DocId}; {ok, #doc{deleted = true, revs = Revs}} -> @@ -938,9 +939,10 @@ send_all_docs_keys(Db, #mrargs{} = Args, VAcc0) -> } end, Row1 = fabric_view:transform_row(Row0), - {ok, NewAcc} = view_cb(Row1, Acc), - NewAcc - end, VAcc1, Keys). + view_cb(Row1, Acc) + end, + {ok, VAcc2} = fabric2_db:fold_docs(Db, Keys, CB, VAcc1, OpenOpts), + VAcc2. apply_args_to_keylist(Args, Keys0) -> |