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 2014/03/11 18:10:29 UTC
[1/2] fabric commit: updated refs/heads/1993-bigcouch-couch-mrview to
fa73a5d
Repository: couchdb-fabric
Updated Branches:
refs/heads/1993-bigcouch-couch-mrview acc45b411 -> fa73a5dc5
Use meta everywhere instead of total_and_offset
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/3eab4d6e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/3eab4d6e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/3eab4d6e
Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: 3eab4d6e270a3ceaba317acf869fed7b2d131e91
Parents: acc45b4
Author: Russell Branca <ch...@apache.org>
Authored: Tue Mar 11 13:08:02 2014 -0400
Committer: Russell Branca <ch...@apache.org>
Committed: Tue Mar 11 13:08:02 2014 -0400
----------------------------------------------------------------------
src/fabric_rpc.erl | 9 ++-------
src/fabric_view_all_docs.erl | 4 +++-
src/fabric_view_map.erl | 4 +++-
src/fabric_view_reduce.erl | 4 ++--
4 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3eab4d6e/src/fabric_rpc.erl
----------------------------------------------------------------------
diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl
index 5727f6d..f61933b 100644
--- a/src/fabric_rpc.erl
+++ b/src/fabric_rpc.erl
@@ -180,11 +180,8 @@ get_or_create_db(DbName, Options) ->
view_cb({meta, Meta}, Acc) ->
% Map function starting
- Total = couch_util:get_value(total, Meta),
- Offset = couch_util:get_value(offset, Meta),
- case rexi:sync_reply({total_and_offset, Total, Offset}) of
+ case rexi:sync_reply({meta, Meta}) of
ok ->
- %% {ok, Acc#vacc{total=Total, offset=Offset}};
{ok, Acc};
stop ->
exit(normal);
@@ -213,9 +210,7 @@ view_cb(complete, Acc) ->
reduce_cb({meta, Meta}, Acc) ->
% Map function starting
- Total = couch_util:get_value(total, Meta),
- Offset = couch_util:get_value(offset, Meta),
- case rexi:sync_reply({total_and_offset, Total, Offset}) of
+ case rexi:sync_reply({meta, Meta}) of
ok ->
{ok, Acc};
stop ->
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3eab4d6e/src/fabric_view_all_docs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl
index 03ed09b..65cfd46 100644
--- a/src/fabric_view_all_docs.erl
+++ b/src/fabric_view_all_docs.erl
@@ -95,7 +95,9 @@ handle_message({rexi_EXIT, Reason}, Worker, State) ->
{error, Resp}
end;
-handle_message({total_and_offset, Tot, Off}, {Worker, From}, State) ->
+handle_message({meta, Meta0}, {Worker, From}, State) ->
+ Tot = couch_util:get_value(total, Meta0, 0),
+ Off = couch_util:get_value(offset, Meta0, 0),
#collector{
callback = Callback,
counters = Counters0,
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3eab4d6e/src/fabric_view_map.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_map.erl b/src/fabric_view_map.erl
index afcdfa0..eb30179 100644
--- a/src/fabric_view_map.erl
+++ b/src/fabric_view_map.erl
@@ -66,7 +66,9 @@ handle_message({rexi_EXIT, Reason}, Worker, State) ->
{error, Resp}
end;
-handle_message({total_and_offset, Tot, Off}, {Worker, From}, State) ->
+handle_message({meta, Meta0}, {Worker, From}, State) ->
+ Tot = couch_util:get_value(total, Meta0, 0),
+ Off = couch_util:get_value(offset, Meta0, 0),
#collector{
callback = Callback,
counters = Counters0,
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/3eab4d6e/src/fabric_view_reduce.erl
----------------------------------------------------------------------
diff --git a/src/fabric_view_reduce.erl b/src/fabric_view_reduce.erl
index 17103a5..6b40a6a 100644
--- a/src/fabric_view_reduce.erl
+++ b/src/fabric_view_reduce.erl
@@ -82,7 +82,7 @@ handle_message({rexi_EXIT, Reason}, Worker, State) ->
%% did not get a total_and_offset call, whereas now we do. We now use this
%% message as a clean way to indicate to couch_mrview_http:view_cb that the
%% reduce response is starting.
-handle_message({total_and_offset, _, _}, {_Worker, From}, State) ->
+handle_message({meta, Meta}, {_Worker, From}, State) ->
gen_server:reply(From, ok),
#collector{
callback = Callback,
@@ -92,7 +92,7 @@ handle_message({total_and_offset, _, _}, {_Worker, From}, State) ->
{Go, Acc} = case get(meta_sent) of
undefined ->
put(meta_sent, true),
- Callback({meta, []}, AccIn);
+ Callback({meta, Meta}, AccIn);
_ ->
{ok, AccIn}
end,
[2/2] fabric commit: updated refs/heads/1993-bigcouch-couch-mrview to
fa73a5d
Posted by ch...@apache.org.
Use ddoc_to_mrst instead of trying to load the local view
This fixes a problem where loading the view locally assumes that the
database is actually on the node in question, which is not a safe
assumption to make. This takes the ddoc and passes it through
ddoc_to_mrst which will allow us to do validation on the request and
also to determine whether or not the given view queried is a reduce
view.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/fa73a5dc
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/fa73a5dc
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/fa73a5dc
Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: fa73a5dc5290be5d921c0fbaf1a144930f56bca8
Parents: 3eab4d6
Author: Russell Branca <ch...@apache.org>
Authored: Tue Mar 11 13:10:34 2014 -0400
Committer: Russell Branca <ch...@apache.org>
Committed: Tue Mar 11 13:10:34 2014 -0400
----------------------------------------------------------------------
src/fabric.erl | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/fa73a5dc/src/fabric.erl
----------------------------------------------------------------------
diff --git a/src/fabric.erl b/src/fabric.erl
index 24bd9b8..5be6f49 100644
--- a/src/fabric.erl
+++ b/src/fabric.erl
@@ -280,23 +280,20 @@ query_view(DbName, DesignName, ViewName, QueryArgs) ->
any().
query_view(DbName, GroupId, ViewName, Callback, Acc0, QueryArgs)
when is_binary(GroupId) ->
- {ok, DDoc} = fabric:open_doc(DbName, <<"_design/", GroupId/binary>>, []),
+ {ok, DDoc} = ddoc_cache:open(DbName, <<"_design/", GroupId/binary>>),
query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs);
-query_view(DbName, Design, ViewName, Callback, Acc0, QueryArgs0) ->
+query_view(DbName, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
Db = dbname(DbName), View = name(ViewName),
- {VInfo, QueryArgs2} = couch_util:with_db(
- Db,
- fun(WDb) ->
- {ok, VInfo0, _Sig, QueryArgs1} =
- couch_mrview_util:get_view(WDb, Design, ViewName, QueryArgs0),
- {VInfo0, QueryArgs1}
- end
- ),
- case is_reduce_view(VInfo) of
+ {ok, #mrst{views=Views, language=Lang}} =
+ couch_mrview_util:ddoc_to_mrst(Db, DDoc),
+ QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views),
+ QueryArgs2 = couch_mrview_util:validate_args(QueryArgs1),
+ VInfo = couch_mrview_util:extract_view(Lang, QueryArgs2, View, Views),
+ case is_reduce_view(QueryArgs2) of
true ->
fabric_view_reduce:go(
Db,
- Design,
+ DDoc,
View,
QueryArgs2,
Callback,
@@ -304,7 +301,7 @@ query_view(DbName, Design, ViewName, Callback, Acc0, QueryArgs0) ->
VInfo
);
false ->
- fabric_view_map:go(Db, Design, View, QueryArgs2, Callback, Acc0)
+ fabric_view_map:go(Db, DDoc, View, QueryArgs2, Callback, Acc0)
end.
%% @doc retrieve info about a view group, disk size, language, whether compaction
@@ -456,6 +453,8 @@ default_callback(complete, Acc) ->
default_callback(Row, Acc) ->
{ok, [Row | Acc]}.
+is_reduce_view(#mrargs{view_type=ViewType}) ->
+ ViewType =:= red;
is_reduce_view({Reduce, _, _}) ->
Reduce =:= red.