You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/03/23 19:28:00 UTC

[couchdb] branch prototype/fdb-layer-get-design-docs created (now 4fb3fc9)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to branch prototype/fdb-layer-get-design-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 4fb3fc9  Implement fabric2_db:get_design_docs/1

This branch includes the following new commits:

     new 4fb3fc9  Implement fabric2_db:get_design_docs/1

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Implement fabric2_db:get_design_docs/1

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/fdb-layer-get-design-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4fb3fc938dfaf73beac370b6086d14e4078df09c
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Mar 23 14:27:32 2020 -0500

    Implement fabric2_db:get_design_docs/1
    
    This is a more efficient method to get all of the design documents than
    relying on fabric2_db:fold_docs which doesn't load doc bodies in
    parallel.
---
 src/fabric/src/fabric2_db.erl | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/fabric/src/fabric2_db.erl b/src/fabric/src/fabric2_db.erl
index 129dea2..6b69437 100644
--- a/src/fabric/src/fabric2_db.erl
+++ b/src/fabric/src/fabric2_db.erl
@@ -80,9 +80,7 @@
     get_full_doc_info/2,
     get_full_doc_infos/2,
     get_missing_revs/2,
-    %% get_design_doc/2,
-    %% get_design_docs/1,
-    %% get_design_doc_count/1,
+    get_design_docs/1,
     %% get_purge_infos/2,
 
     %% get_minimum_purge_seq/1,
@@ -657,6 +655,28 @@ get_missing_revs(Db, JsonIdRevs) ->
     {ok, AllMissing}.
 
 
+get_design_docs(Db) ->
+    fabric2_fdb:transactional(Db, fun(TxDb) ->
+        #{
+            db_prefix := DbPrefix
+        } = TxDb,
+
+        Prefix = erlfdb_tuple:pack({?DB_CHANGES}, DbPrefix),
+        Options = set_design_doc_keys([]),
+        FoldFun = fun({Key, Val}, Acc) ->
+            {DocId} = erlfdb_tuple:unpack(K, Prefix),
+            RevId = erlfdb_tuple:unpack(V),
+            Future = get_doc_body_future(TxDb, DocId, RevId),
+            [Future | Acc]
+        end,
+        {ok, Futs} = fabric2_fdb:fold_range(TxDb, Prefix, FoldFun, [], Options),
+
+        lists:foldl(fun(Future, Acc) ->
+            [fabric2_fdb:get_doc_body_wait(Future) | Acc]
+        end, [], Futs)
+    end).
+
+
 validate_docid(<<"">>) ->
     throw({illegal_docid, <<"Document id must not be empty">>});
 validate_docid(<<"_design/">>) ->