You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2015/10/13 00:02:38 UTC

[1/4] couch commit: updated refs/heads/master to eb60e41

Repository: couchdb-couch
Updated Branches:
  refs/heads/master 75cfed07b -> eb60e41ad


Whitespace and housekeeping


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

Branch: refs/heads/master
Commit: c0822a7ecb7fbf34dd2bd67a019580ff32bf8e6b
Parents: 62994cc
Author: Russell Branca <ch...@apache.org>
Authored: Mon Oct 12 19:26:30 2015 +0000
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Oct 12 22:01:14 2015 +0000

----------------------------------------------------------------------
 src/couch_query_servers.erl | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c0822a7e/src/couch_query_servers.erl
----------------------------------------------------------------------
diff --git a/src/couch_query_servers.erl b/src/couch_query_servers.erl
index 34c54d0..92ba3a3 100644
--- a/src/couch_query_servers.erl
+++ b/src/couch_query_servers.erl
@@ -273,14 +273,13 @@ get_number(Key, Props) ->
 validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) ->
     JsonEditDoc = couch_doc:to_json_obj(EditDoc, [revs]),
     JsonDiskDoc = json_doc(DiskDoc),
-    Resp = ddoc_prompt(DDoc,
-                       [<<"validate_doc_update">>],
-                       [JsonEditDoc, JsonDiskDoc, Ctx, SecObj]),
-    case Resp of
-        _ when Resp /= 1 ->
-            couch_stats:increment_counter(
-                [couchdb, query_server, vdu_rejects], 1);
-        _ -> ok
+    Resp = ddoc_prompt(
+        DDoc,
+        [<<"validate_doc_update">>],
+        [JsonEditDoc, JsonDiskDoc, Ctx, SecObj]
+    ),
+    if Resp == 1 -> ok; true ->
+        couch_stats:increment_counter([couchdb, query_server, vdu_rejects], 1)
     end,
     case Resp of
         1 ->
@@ -316,10 +315,10 @@ filter_view(DDoc, VName, Docs) ->
 
 filter_docs(Req, Db, DDoc, FName, Docs) ->
     JsonReq = case Req of
-    {json_req, JsonObj} ->
-        JsonObj;
-    #httpd{} = HttpReq ->
-        couch_httpd_external:json_req_obj(HttpReq, Db)
+        {json_req, JsonObj} ->
+            JsonObj;
+        #httpd{} = HttpReq ->
+            couch_httpd_external:json_req_obj(HttpReq, Db)
     end,
     Options = json_doc_options(),
     JsonDocs = [json_doc(Doc, Options) || Doc <- Docs],


[4/4] couch commit: updated refs/heads/master to eb60e41

Posted by ch...@apache.org.
Merge branch 'add-filter-revs-limit'


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

Branch: refs/heads/master
Commit: eb60e41ad0afdad1281455e19cf1bf02419864d4
Parents: 75cfed0 c0822a7
Author: Russell Branca <ch...@apache.org>
Authored: Mon Oct 12 22:02:14 2015 +0000
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Oct 12 22:02:14 2015 +0000

----------------------------------------------------------------------
 include/couch_db.hrl        |  7 ++++++
 src/couch_doc.erl           | 17 +++++++++----
 src/couch_query_servers.erl | 52 +++++++++++++++++++++++++++-------------
 3 files changed, 55 insertions(+), 21 deletions(-)
----------------------------------------------------------------------



[3/4] couch commit: updated refs/heads/master to eb60e41

Posted by ch...@apache.org.
Add revs limit for docs passed to filter functions

The existing revs_limit logic only accounts for depth of individual
branches, and ignores the case where you have a lot of branches, for
instance when a doc is heavily conflicted. This patch truncates the list
of revs when passing docs to the JS filter functions, because given
enough revs this can cause the couchjs processes to explode.


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

Branch: refs/heads/master
Commit: 23e5f92a15cdc868622481d2ff63ca3770110fae
Parents: 75cfed0
Author: Russell Branca <ch...@apache.org>
Authored: Tue Sep 29 20:32:02 2015 +0000
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Oct 12 22:01:14 2015 +0000

----------------------------------------------------------------------
 src/couch_doc.erl           | 17 ++++++++++++-----
 src/couch_query_servers.erl | 21 +++++++++++++++++----
 2 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/23e5f92a/src/couch_doc.erl
----------------------------------------------------------------------
diff --git a/src/couch_doc.erl b/src/couch_doc.erl
index 57e8929..d3f0cb8 100644
--- a/src/couch_doc.erl
+++ b/src/couch_doc.erl
@@ -48,14 +48,21 @@ to_json_body(true, {Body}) ->
 to_json_body(false, {Body}) ->
     Body.
 
-to_json_revisions(Options, Start, RevIds) ->
-    case lists:member(revs, Options) of
-    false -> [];
-    true ->
+to_json_revisions(Options, Start, RevIds0) ->
+    RevIds = case proplists:get_value(revs, Options) of
+        true ->
+            RevIds0;
+        Num when is_integer(Num), Num > 0 ->
+            lists:sublist(RevIds0, Num);
+        _ ->
+           []
+    end,
+    if RevIds == [] -> []; true ->
         [{<<"_revisions">>, {[{<<"start">>, Start},
-                {<<"ids">>, [revid_to_str(R) ||R <- RevIds]}]}}]
+            {<<"ids">>, [revid_to_str(R) ||R <- RevIds]}]}}]
     end.
 
+
 revid_to_str(RevId) when size(RevId) =:= 16 ->
     ?l2b(couch_util:to_hex(RevId));
 revid_to_str(RevId) ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/23e5f92a/src/couch_query_servers.erl
----------------------------------------------------------------------
diff --git a/src/couch_query_servers.erl b/src/couch_query_servers.erl
index 97884c2..024122e 100644
--- a/src/couch_query_servers.erl
+++ b/src/couch_query_servers.erl
@@ -285,12 +285,24 @@ validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) ->
             throw({unknown_error, Message})
     end.
 
-json_doc(nil) -> null;
+json_doc_options() ->
+    json_doc_options([]).
+
+json_doc_options(Options) ->
+    Limit = config:get_integer("query_server_config", "revs_limit", 20),
+    [{revs, Limit} | Options].
+
 json_doc(Doc) ->
-    couch_doc:to_json_obj(Doc, [revs]).
+    json_doc(Doc, json_doc_options()).
+
+json_doc(nil, _) ->
+    null;
+json_doc(Doc, Options) ->
+    couch_doc:to_json_obj(Doc, Options).
 
 filter_view(DDoc, VName, Docs) ->
-    JsonDocs = [couch_doc:to_json_obj(Doc, [revs]) || Doc <- Docs],
+    Options = json_doc_options(),
+    JsonDocs = [json_doc(Doc, Options) || Doc <- Docs],
     [true, Passes] = ddoc_prompt(DDoc, [<<"views">>, VName, <<"map">>], [JsonDocs]),
     {ok, Passes}.
 
@@ -301,7 +313,8 @@ filter_docs(Req, Db, DDoc, FName, Docs) ->
     #httpd{} = HttpReq ->
         couch_httpd_external:json_req_obj(HttpReq, Db)
     end,
-    JsonDocs = [couch_doc:to_json_obj(Doc, [revs]) || Doc <- Docs],
+    Options = json_doc_options(),
+    JsonDocs = [json_doc(Doc, Options) || Doc <- Docs],
     [true, Passes] = ddoc_prompt(DDoc, [<<"filters">>, FName],
         [JsonDocs, JsonReq]),
     {ok, Passes}.


[2/4] couch commit: updated refs/heads/master to eb60e41

Posted by ch...@apache.org.
Add specs to document validate_doc_update/5


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

Branch: refs/heads/master
Commit: 62994cca3ef4c8f9952d1f2f3757b499b22b83d0
Parents: 23e5f92
Author: Russell Branca <ch...@apache.org>
Authored: Mon Oct 12 19:26:05 2015 +0000
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Oct 12 22:01:14 2015 +0000

----------------------------------------------------------------------
 include/couch_db.hrl        | 7 +++++++
 src/couch_query_servers.erl | 8 ++++++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/62994cca/include/couch_db.hrl
----------------------------------------------------------------------
diff --git a/include/couch_db.hrl b/include/couch_db.hrl
index 3c4eacf..a7a1fdb 100644
--- a/include/couch_db.hrl
+++ b/include/couch_db.hrl
@@ -229,3 +229,10 @@
     atts = []
 }).
 
+
+-type doc() :: #doc{}.
+-type ddoc() :: #doc{}.
+-type user_ctx() :: #user_ctx{}.
+-type sec_props() :: [tuple()].
+-type sec_obj() :: {sec_props()}.
+

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/62994cca/src/couch_query_servers.erl
----------------------------------------------------------------------
diff --git a/src/couch_query_servers.erl b/src/couch_query_servers.erl
index 024122e..34c54d0 100644
--- a/src/couch_query_servers.erl
+++ b/src/couch_query_servers.erl
@@ -261,7 +261,15 @@ get_number(Key, Props) ->
         throw({invalid_value, iolist_to_binary(Msg)})
     end.
 
+
 % use the function stored in ddoc.validate_doc_update to test an update.
+-spec validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) -> ok when
+    DDoc    :: ddoc(),
+    EditDoc :: doc(),
+    DiskDoc :: doc() | nil,
+    Ctx     :: user_ctx(),
+    SecObj  :: sec_obj().
+
 validate_doc_update(DDoc, EditDoc, DiskDoc, Ctx, SecObj) ->
     JsonEditDoc = couch_doc:to_json_obj(EditDoc, [revs]),
     JsonDiskDoc = json_doc(DiskDoc),