couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject [3/5] git commit: couch_db:get_design_docs/1 -> #full_doc_info{}
Date Wed, 09 Nov 2011 10:07:20 GMT
couch_db:get_design_docs/1 -> #full_doc_info{}

Rather than open every design doc at once with this call, just return
the full doc info. It's the cheapest thing to do because it lets other
code open the documents as needed.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/13f704bf
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/13f704bf
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/13f704bf

Branch: refs/heads/master
Commit: 13f704bf18f992f4538d78c4277758fe0bd09d8b
Parents: c2c8d63
Author: Randall Leeds <randall@apache.org>
Authored: Wed Nov 9 01:33:47 2011 -0800
Committer: Randall Leeds <randall@apache.org>
Committed: Wed Nov 9 01:42:10 2011 -0800

----------------------------------------------------------------------
 src/couch_mrview/src/couch_mrview_cleanup.erl |    7 ++++---
 src/couchdb/couch_db.erl                      |    5 ++---
 src/couchdb/couch_db_updater.erl              |    6 ++++--
 3 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/13f704bf/src/couch_mrview/src/couch_mrview_cleanup.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview/src/couch_mrview_cleanup.erl b/src/couch_mrview/src/couch_mrview_cleanup.erl
index 24e3e67..d48de6f 100644
--- a/src/couch_mrview/src/couch_mrview_cleanup.erl
+++ b/src/couch_mrview/src/couch_mrview_cleanup.erl
@@ -23,14 +23,15 @@ run(Db) ->
     RootDir = couch_index_util:root_dir(),
     DbName = couch_db:name(Db),
 
-    {ok, DesignDocs} = couch_db:get_design_docs(Db),
-    SigFiles = lists:foldl(fun(DDoc, SFAcc) ->
+    DesignDocs = couch_db:get_design_docs(Db),
+    SigFiles = lists:foldl(fun(DDocInfo, SFAcc) ->
+        {ok, DDoc} = couch_db:open_doc_int(Db, DDocInfo, [ejson_body]),
         {ok, InitState} = couch_mrview_util:ddoc_to_mrst(DbName, DDoc),
         Sig = InitState#mrst.sig,
         IFName = couch_mrview_util:index_file(DbName, Sig),
         CFName = couch_mrview_util:compaction_file(DbName, Sig),
         [IFName, CFName | SFAcc]
-    end, [], [DD || DD <- DesignDocs, DD#doc.deleted == false]),
+    end, [], [DD || DD <- DesignDocs, DD#full_doc_info.deleted == false]),
 
     IdxDir = couch_index_util:index_dir(mrview, DbName),
     DiskFiles = filelib:wildcard(filename:join(IdxDir, "*")),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/13f704bf/src/couchdb/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index ec1dbd8..0656b52 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -306,14 +306,13 @@ get_design_docs(Db) ->
         (#full_doc_info{deleted = true}, _Reds, Acc) ->
             {ok, Acc};
         (#full_doc_info{id= <<"_design/",_/binary>>}=FullDocInfo, _Reds, Acc)
->
-            {ok, Doc} = open_doc_int(Db, FullDocInfo, [ejson_body]),
-            {ok, [Doc | Acc]};
+            {ok, [FullDocInfo | Acc]};
         (_, _Reds, Acc) ->
             {stop, Acc}
     end),
     KeyOpts = [{start_key, <<"_design/">>}, {end_key_gt, <<"_design0">>}],
     {ok, _, Docs} = couch_btree:fold(by_id_btree(Db), FoldFun, [], KeyOpts),
-    {ok, Docs}.
+    Docs.
 
 check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) ->
     {Admins} = get_admins(Db),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/13f704bf/src/couchdb/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index b24fc56..38cf658 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -496,9 +496,11 @@ close_db(#db{fd_ref_counter = RefCntr}) ->
 
 
 refresh_validate_doc_funs(Db) ->
-    {ok, DesignDocs} = couch_db:get_design_docs(Db),
+    DesignDocs = couch_db:get_design_docs(Db),
     ProcessDocFuns = lists:flatmap(
-        fun(DesignDoc) ->
+        fun(DesignDocInfo) ->
+            {ok, DesignDoc} = couch_db:open_doc_int(
+                Db, DesignDocInfo, [ejson_body]),
             case couch_doc:get_validate_doc_fun(DesignDoc) of
             nil -> [];
             Fun -> [Fun]


Mime
View raw message