Purge view_query_args and point to mrargs (when rebasing, pull in the other bits from ba152cb2153e892c0d8eec7f6fbeecf3dcaff10a)
diff --git a/src/fabric.erl b/src/fabric.erl
index 4b8fe4a..1f05ed6 100644
--- a/src/fabric.erl
+++ b/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 @@
%% 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, 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 @@
%% 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 @@
%% @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(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_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 @@
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 @@
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),
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index 1f9f460..1415c82 100644
--- a/src/fabric_view_all_docs.erl
+++ b/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, QueryArgs, Callback, Acc0) ->
- #view_query_args{
+ #mrargs{
direction = Dir,
include_docs = IncludeDocs,
limit = Limit,
@@ -134,7 +135,7 @@
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},
diff --git a/src/fabric_view_map.erl b/src/fabric_view_map.erl
index 9403bde..9e41c11 100644
--- a/src/fabric_view_map.erl
+++ b/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, 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 @@
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, {Worker, From}, State) ->
#collector{
- query_args = #view_query_args{direction=Dir},
+ query_args = #mrargs{direction=Dir},
counters = Counters0,
rows = Rows0,
keys = KeyDict