You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/02/03 13:59:57 UTC

[18/27] couchdb commit: updated refs/heads/1843-feature-bigcouch to 465d1ad

Purge view_query_args and point to mrargs (when rebasing, pull in the other bits from ba152cb2153e892c0d8eec7f6fbeecf3dcaff10a)


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

Branch: refs/heads/1843-feature-bigcouch
Commit: a1eea29e4576a11d578c53116f1f96690f3227ea
Parents: cbbef5c
Author: Robert Newson <rn...@apache.org>
Authored: Mon Dec 23 11:44:52 2013 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Mon Feb 3 12:54:10 2014 +0000

----------------------------------------------------------------------
 src/chttpd/src/chttpd_misc.erl          |  3 ++-
 src/couch/include/couch_db.hrl          | 26 --------------------------
 src/couch/src/couch_db.erl              |  2 +-
 src/fabric/src/fabric.erl               | 27 ++++++++++++++-------------
 src/fabric/src/fabric_view_all_docs.erl |  9 +++++----
 src/fabric/src/fabric_view_map.erl      |  7 ++++---
 6 files changed, 26 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/chttpd/src/chttpd_misc.erl
----------------------------------------------------------------------
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index a730801..8c5f50e 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -21,6 +21,7 @@
 
 
 -include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
 
 -import(chttpd,
     [send_json/2,send_json/3,send_method_not_allowed/2,
@@ -96,7 +97,7 @@ handle_all_dbs_req(#httpd{method='GET'}=Req) ->
     chttpd:etag_respond(Req, Etag, fun() ->
         {ok, Resp} = chttpd:start_delayed_json_response(Req, 200, [{"Etag",Etag}]),
         fabric:all_docs(ShardDbName, fun all_dbs_callback/2,
-            {nil, Resp}, #view_query_args{})
+            {nil, Resp}, #mrargs{})
     end);
 handle_all_dbs_req(Req) ->
     send_method_not_allowed(Req, "GET,HEAD").

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/couch/include/couch_db.hrl
----------------------------------------------------------------------
diff --git a/src/couch/include/couch_db.hrl b/src/couch/include/couch_db.hrl
index 61a59f7..ffecae0 100644
--- a/src/couch/include/couch_db.hrl
+++ b/src/couch/include/couch_db.hrl
@@ -179,32 +179,6 @@
     after_doc_read = nil     % nil | fun(Doc, Db) -> NewDoc
     }).
 
-
--record(view_query_args, {
-    start_key,
-    end_key,
-    start_docid = ?MIN_STR,
-    end_docid = ?MAX_STR,
-
-    direction = fwd,
-    inclusive_end=true, % aka a closed-interval
-
-    limit = 10000000000, % Huge number to simplify logic
-    skip = 0,
-
-    group_level = 0,
-
-    view_type = nil,
-    include_docs = false,
-    conflicts = false,
-    stale = false,
-    multi_get = false,
-    callback = nil,
-    list = nil,
-    keys = nil,
-    sorted = true
-}).
-
 -record(view_fold_helper_funs, {
     reduce_count,
     passed_end,

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/couch/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch/src/couch_db.erl b/src/couch/src/couch_db.erl
index e4e8cca..32a0049 100644
--- a/src/couch/src/couch_db.erl
+++ b/src/couch/src/couch_db.erl
@@ -291,7 +291,7 @@ get_last_purged(#db{fd=Fd, header=#db_header{purged_docs=PurgedPointer}}) ->
     couch_file:pread_term(Fd, PurgedPointer).
 
 get_doc_count(Db) ->
-    {ok, {Count, _DelCount}} = couch_btree:full_reduce(Db#db.id_tree),
+    {ok, {Count, _, _}} = couch_btree:full_reduce(Db#db.id_tree),
     {ok, Count}.
 
 get_db_info(Db) ->

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/fabric/src/fabric.erl
----------------------------------------------------------------------
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index 4b8fe4a..1f05ed6 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -14,6 +14,7 @@
 
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
 
 -define(ADMIN_CTX, {user_ctx, #user_ctx{roles = [<<"_admin">>]}}).
 
@@ -237,9 +238,9 @@ att_receiver(Req, Length) ->
 %%      also be passed to further constrain the query. See <a href=
 %%      "http://wiki.apache.org/couchdb/HTTP_Document_API#All_Documents">
 %%      all_docs</a> for details
--spec all_docs(dbname(), callback(), [] | tuple(), #view_query_args{}) ->
+-spec all_docs(dbname(), callback(), [] | tuple(), #mrargs{}) ->
     {ok, [any()]}.
-all_docs(DbName, Callback, Acc0, #view_query_args{} = QueryArgs) when
+all_docs(DbName, Callback, Acc0, #mrargs{} = QueryArgs) when
         is_function(Callback, 2) ->
     fabric_view_all_docs:go(dbname(DbName), QueryArgs, Callback, Acc0);
 
@@ -260,9 +261,9 @@ changes(DbName, Callback, Acc0, #changes_args{}=Options) ->
 changes(DbName, Callback, Acc0, Options) ->
     changes(DbName, Callback, Acc0, kl_to_changes_args(Options)).
 
-%% @equiv query_view(DbName, DesignName, ViewName, #view_query_args{})
+%% @equiv query_view(DbName, DesignName, ViewName, #mrargs{})
 query_view(DbName, DesignName, ViewName) ->
-    query_view(DbName, DesignName, ViewName, #view_query_args{}).
+    query_view(DbName, DesignName, ViewName, #mrargs{}).
 
 %% @equiv query_view(DbName, DesignName,
 %%                     ViewName, fun default_callback/2, [], QueryArgs)
@@ -275,7 +276,7 @@ query_view(DbName, DesignName, ViewName, QueryArgs) ->
 %%      see <a href="http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options">
 %%      query args</a> for details.
 -spec query_view(dbname(), #doc{} | binary(), iodata(), callback(), any(),
-        #view_query_args{}) ->
+        #mrargs{}) ->
     any().
 query_view(DbName, Design, ViewName, Callback, Acc0, QueryArgs) ->
     Db = dbname(DbName), View = name(ViewName),
@@ -307,7 +308,7 @@ get_view_group_info(DbName, DesignId) ->
 %% @doc retrieve all the design docs from a database
 -spec design_docs(dbname()) -> {ok, [json_obj()]}.
 design_docs(DbName) ->
-    QueryArgs = #view_query_args{
+    QueryArgs = #mrargs{
         start_key = <<"_design/">>,
         end_key = <<"_design0">>,
         include_docs=true
@@ -436,7 +437,7 @@ default_callback(complete, Acc) ->
 default_callback(Row, Acc) ->
     {ok, [Row | Acc]}.
 
-is_reduce_view(_, _, _, #view_query_args{view_type=Reduce}) ->
+is_reduce_view(_, _, _, #mrargs{view_type=Reduce}) ->
     Reduce =:= reduce.
 
 %% @doc convenience method for use in the shell, converts a keylist
@@ -445,9 +446,9 @@ kl_to_changes_args(KeyList) ->
     kl_to_record(KeyList, changes_args).
 
 %% @doc convenience method for use in the shell, converts a keylist
-%%      to a `view_query_args' record
+%%      to a `mrargs' record
 kl_to_query_args(KeyList) ->
-    kl_to_record(KeyList, view_query_args).
+    kl_to_record(KeyList, mrargs).
 
 %% @doc finds the index of the given Key in the record.
 %%      note that record_info is only known at compile time
@@ -459,9 +460,9 @@ lookup_index(Key,RecName) ->
         changes_args ->
             lists:zip(record_info(fields, changes_args),
                         lists:seq(2, record_info(size, changes_args)));
-        view_query_args ->
-            lists:zip(record_info(fields, view_query_args),
-                        lists:seq(2, record_info(size, view_query_args)))
+        mrargs ->
+            lists:zip(record_info(fields, mrargs),
+                        lists:seq(2, record_info(size, mrargs)))
         end,
     couch_util:get_value(Key, Indexes).
 
@@ -470,7 +471,7 @@ lookup_index(Key,RecName) ->
 kl_to_record(KeyList,RecName) ->
     Acc0 = case RecName of
           changes_args -> #changes_args{};
-          view_query_args -> #view_query_args{}
+          mrargs -> #mrargs{}
           end,
     lists:foldl(fun({Key, Value}, Acc) ->
                     Index = lookup_index(couch_util:to_existing_atom(Key),RecName),

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/fabric/src/fabric_view_all_docs.erl
----------------------------------------------------------------------
diff --git a/src/fabric/src/fabric_view_all_docs.erl b/src/fabric/src/fabric_view_all_docs.erl
index 1f9f460..1415c82 100644
--- a/src/fabric/src/fabric_view_all_docs.erl
+++ b/src/fabric/src/fabric_view_all_docs.erl
@@ -18,10 +18,11 @@
 -include_lib("fabric/include/fabric.hrl").
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
 
-go(DbName, #view_query_args{keys=undefined} = QueryArgs, Callback, Acc0) ->
+go(DbName, #mrargs{keys=undefined} = QueryArgs, Callback, Acc0) ->
     Workers = fabric_util:submit_jobs(mem3:shards(DbName),all_docs,[QueryArgs]),
-    #view_query_args{limit = Limit, skip = Skip} = QueryArgs,
+    #mrargs{limit = Limit, skip = Skip} = QueryArgs,
     State = #collector{
         query_args = QueryArgs,
         callback = Callback,
@@ -46,7 +47,7 @@ go(DbName, #view_query_args{keys=undefined} = QueryArgs, Callback, Acc0) ->
 
 
 go(DbName, QueryArgs, Callback, Acc0) ->
-    #view_query_args{
+    #mrargs{
         direction = Dir,
         include_docs = IncludeDocs,
         limit = Limit,
@@ -134,7 +135,7 @@ handle_message({total_and_offset, Tot, Off}, {Worker, From}, State) ->
 
 handle_message(#view_row{} = Row, {Worker, From}, State) ->
     #collector{query_args = Args, counters = Counters0, rows = Rows0} = State,
-    Dir = Args#view_query_args.direction,
+    Dir = Args#mrargs.direction,
     Rows = merge_row(Dir, Row#view_row{worker={Worker, From}}, Rows0),
     Counters1 = fabric_dict:update_counter(Worker, 1, Counters0),
     State1 = State#collector{rows=Rows, counters=Counters1},

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a1eea29e/src/fabric/src/fabric_view_map.erl
----------------------------------------------------------------------
diff --git a/src/fabric/src/fabric_view_map.erl b/src/fabric/src/fabric_view_map.erl
index 9403bde..9e41c11 100644
--- a/src/fabric/src/fabric_view_map.erl
+++ b/src/fabric/src/fabric_view_map.erl
@@ -17,6 +17,7 @@
 -include_lib("fabric/include/fabric.hrl").
 -include_lib("mem3/include/mem3.hrl").
 -include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
 
 go(DbName, GroupId, View, Args, Callback, Acc0) when is_binary(GroupId) ->
     {ok, DDoc} = fabric:open_doc(DbName, <<"_design/", GroupId/binary>>, []),
@@ -25,7 +26,7 @@ go(DbName, GroupId, View, Args, Callback, Acc0) when is_binary(GroupId) ->
 go(DbName, DDoc, View, Args, Callback, Acc0) ->
     Shards = fabric_view:get_shards(DbName, Args),
     Workers = fabric_util:submit_jobs(Shards, map_view, [DDoc, View, Args]),
-    #view_query_args{limit = Limit, skip = Skip, keys = Keys} = Args,
+    #mrargs{limit = Limit, skip = Skip, keys = Keys} = Args,
     State = #collector{
         db_name=DbName,
         query_args = Args,
@@ -34,7 +35,7 @@ go(DbName, DDoc, View, Args, Callback, Acc0) ->
         skip = Skip,
         limit = Limit,
         keys = fabric_view:keydict(Keys),
-        sorted = Args#view_query_args.sorted,
+        sorted = Args#mrargs.sorted,
         user_acc = Acc0
     },
     RexiMon = fabric_util:create_monitors(Workers),
@@ -116,7 +117,7 @@ handle_message(#view_row{} = Row, {_,From}, #collector{sorted=false} = St) ->
 
 handle_message(#view_row{} = Row, {Worker, From}, State) ->
     #collector{
-        query_args = #view_query_args{direction=Dir},
+        query_args = #mrargs{direction=Dir},
         counters = Counters0,
         rows = Rows0,
         keys = KeyDict