Build with rebar
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/63bfcfea Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/63bfcfea Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/63bfcfea Branch: refs/heads/import Commit: 63bfcfea8222216ca8687538f50f9c88bfa0ae5f Parents: cc7b13b Author: Robert Newson <[email protected]> Authored: Wed Dec 18 14:04:59 2013 +0000 Committer: Paul J. Davis <[email protected]> Committed: Fri Jan 17 13:49:28 2014 -0800 ---------------------------------------------------------------------- .gitignore | 4 --- Makefile.am | 77 ----------------------------------------- src/fabric.app.src | 2 +- src/fabric_rpc.erl | 17 ++++----- src/fabric_view.erl | 13 +++---- src/fabric_view_reduce.erl | 7 ++-- 6 files changed, 21 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 37bfdb0..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.beam -.eunit -ebin/fabric.app -.DS_Store \ No newline at end of file http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/Makefile.am ---------------------------------------------------------------------- diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 64ca935..0000000 --- a/Makefile.am +++ /dev/null @@ -1,77 +0,0 @@ -## Licensed under the Apache License, Version 2.0 (the "License"); you may not -## use this file except in compliance with the License. You may obtain a copy -## of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -## License for the specific language governing permissions and limitations under -## the License. - -fabricebindir = $(localerlanglibdir)/fabric/ebin - -fabricebin_DATA = $(compiled_files) - -source_files = \ - src/fabric.app.src \ - src/fabric.erl \ - src/fabric_db_create.erl \ - src/fabric_db_delete.erl \ - src/fabric_db_doc_count.erl \ - src/fabric_db_info.erl \ - src/fabric_db_meta.erl \ - src/fabric_db_update_listener.erl \ - src/fabric_dict.erl \ - src/fabric_doc_attachments.erl \ - src/fabric_doc_missing_revs.erl \ - src/fabric_doc_open.erl \ - src/fabric_doc_open_revs.erl \ - src/fabric_doc_update.erl \ - src/fabric_group_info.erl \ - src/fabric_rpc.erl \ - src/fabric_util.erl \ - src/fabric_view.erl \ - src/fabric_view_all_docs.erl \ - src/fabric_view_changes.erl \ - src/fabric_view_map.erl \ - src/fabric_view_reduce.erl - -compiled_files = \ - ebin/fabric.app \ - ebin/fabric.beam \ - ebin/fabric_db_create.beam \ - ebin/fabric_db_delete.beam \ - ebin/fabric_db_doc_count.beam \ - ebin/fabric_db_info.beam \ - ebin/fabric_db_meta.beam \ - ebin/fabric_db_update_listener.beam \ - ebin/fabric_dict.beam \ - ebin/fabric_doc_attachments.beam \ - ebin/fabric_doc_missing_revs.beam \ - ebin/fabric_doc_open.beam \ - ebin/fabric_doc_open_revs.beam \ - ebin/fabric_doc_update.beam \ - ebin/fabric_group_info.beam \ - ebin/fabric_util.beam - -# Conflicts in couch_db.hrl prevent us from building these -# until after we merge the couch application -# ebin/fabric_rpc.beam -# ebin/fabric_view.beam -# ebin/fabric_view_all_docs.beam -# ebin/fabric_view_changes.beam -# ebin/fabric_view_map.beam -# ebin/fabric_view_reduce.beam - -EXTRA_DIST = $(source_files) -CLEANFILES = $(compiled_files) - -ebin/%.app: src/%.app.src - @mkdir -p ebin/ - sed -e "s|%version%|@version@|g" < $< > $@ - -ebin/%.beam: src/%.erl - @mkdir -p ebin/ - $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $< http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/src/fabric.app.src ---------------------------------------------------------------------- diff --git a/src/fabric.app.src b/src/fabric.app.src index a3022e6..5ac86ef 100644 --- a/src/fabric.app.src +++ b/src/fabric.app.src @@ -12,7 +12,7 @@ {application, fabric, [ {description, "Routing and proxying layer for CouchDB cluster"}, - {vsn, "%version%"}, + {vsn, git}, {modules, [ fabric, fabric_db_create, http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/src/fabric_rpc.erl ---------------------------------------------------------------------- diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl index 4926609..2685cd7 100644 --- a/src/fabric_rpc.erl +++ b/src/fabric_rpc.erl @@ -22,6 +22,7 @@ -include_lib("fabric/include/fabric.hrl"). -include_lib("couch/include/couch_db.hrl"). +-include_lib("couch_mrview/include/couch_mrview.hrl"). -record (view_acc, { db, @@ -38,13 +39,13 @@ %% rpc endpoints %% call to with_db will supply your M:F with a #db{} and then remaining args -all_docs(DbName, #view_query_args{keys=nil} = QueryArgs) -> +all_docs(DbName, #mrargs{keys=nil} = QueryArgs) -> {ok, Db} = get_or_create_db(DbName, []), - #view_query_args{ + #mrargs{ start_key = StartKey, - start_docid = StartDocId, + start_key_docid = StartDocId, end_key = EndKey, - end_docid = EndDocId, + end_key_docid = EndDocId, limit = Limit, skip = Skip, include_docs = IncludeDocs, @@ -93,7 +94,7 @@ changes(DbName, Options, StartSeq) -> map_view(DbName, DDoc, ViewName, QueryArgs) -> {ok, Db} = get_or_create_db(DbName, []), - #view_query_args{ + #mrargs{ limit = Limit, skip = Skip, keys = Keys, @@ -126,7 +127,7 @@ map_view(DbName, DDoc, ViewName, QueryArgs) -> {ok, _, Acc} = couch_view:fold(View, fun view_fold/3, Acc0, Options); _ -> Acc = lists:foldl(fun(Key, AccIn) -> - KeyArgs = QueryArgs#view_query_args{start_key=Key, end_key=Key}, + KeyArgs = QueryArgs#mrargs{start_key=Key, end_key=Key}, Options = couch_httpd_view:make_key_options(KeyArgs), {_Go, _, Out} = couch_view:fold(View, fun view_fold/3, AccIn, Options), @@ -141,7 +142,7 @@ reduce_view(DbName, #doc{} = DDoc, ViewName, QueryArgs) -> reduce_view(DbName, Group0, ViewName, QueryArgs) -> erlang:put(io_priority, {interactive, DbName}), {ok, Db} = get_or_create_db(DbName, []), - #view_query_args{ + #mrargs{ group_level = GroupLevel, limit = Limit, skip = Skip, @@ -168,7 +169,7 @@ reduce_view(DbName, Group0, ViewName, QueryArgs) -> couch_view:fold_reduce(ReduceView, fun reduce_fold/3, Acc0, Options); _ -> lists:map(fun(Key) -> - KeyArgs = QueryArgs#view_query_args{start_key=Key, end_key=Key}, + KeyArgs = QueryArgs#mrargs{start_key=Key, end_key=Key}, Options0 = couch_httpd_view:make_key_options(KeyArgs), Options = [{key_group_fun, GroupFun} | Options0], couch_view:fold_reduce(ReduceView, fun reduce_fold/3, Acc0, Options) http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/src/fabric_view.erl ---------------------------------------------------------------------- diff --git a/src/fabric_view.erl b/src/fabric_view.erl index a42582b..9cb4b03 100644 --- a/src/fabric_view.erl +++ b/src/fabric_view.erl @@ -19,6 +19,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"). -spec remove_down_shards(#collector{}, node()) -> {ok, #collector{}} | {error, any()}. @@ -139,7 +140,7 @@ possibly_embed_doc(_State, Row; possibly_embed_doc(#collector{db_name=DbName, query_args=Args}, #view_row{key=_Key, id=_Id, value=Value, doc=_Doc}=Row) -> - #view_query_args{include_docs=IncludeDocs} = Args, + #mrargs{include_docs=IncludeDocs} = Args, case IncludeDocs andalso is_tuple(Value) of true -> {Props} = Value, @@ -190,7 +191,7 @@ get_next_row(#collector{rows = []}) -> throw(complete); get_next_row(#collector{reducer = RedSrc} = St) when RedSrc =/= undefined -> #collector{ - query_args = #view_query_args{direction=Dir}, + query_args = #mrargs{direction=Dir}, keys = Keys, rows = RowDict, os_proc = Proc, @@ -269,9 +270,9 @@ extract_view(Pid, ViewName, [View|Rest], ViewType) -> end. view_names(View, Type) when Type == red_map; Type == reduce -> - [Name || {Name, _} <- View#view.reduce_funs]; + [Name || {Name, _} <- View#mrview.reduce_funs]; view_names(View, map) -> - View#view.map_names. + View#mrview.map_names. index_of(X, List) -> index_of(X, List, 1). @@ -283,10 +284,10 @@ index_of(X, [X|_Rest], I) -> index_of(X, [_|Rest], I) -> index_of(X, Rest, I+1). -get_shards(DbName, #view_query_args{stale=Stale}) +get_shards(DbName, #mrargs{stale=Stale}) when Stale == ok orelse Stale == update_after -> mem3:ushards(DbName); -get_shards(DbName, #view_query_args{stale=false}) -> +get_shards(DbName, #mrargs{stale=false}) -> mem3:shards(DbName). % unit test http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/63bfcfea/src/fabric_view_reduce.erl ---------------------------------------------------------------------- diff --git a/src/fabric_view_reduce.erl b/src/fabric_view_reduce.erl index 54dcdf5..c922a7f 100644 --- a/src/fabric_view_reduce.erl +++ b/src/fabric_view_reduce.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>>, []), @@ -27,13 +28,13 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) -> Lang = couch_view_group:get_language(Group), Views = couch_view_group:get_views(Group), {NthRed, View} = fabric_view:extract_view(nil, VName, Views, reduce), - {VName, RedSrc} = lists:nth(NthRed, View#view.reduce_funs), + {VName, RedSrc} = lists:nth(NthRed, View#mrview.reduce_funs), Workers = lists:map(fun(#shard{name=Name, node=N} = Shard) -> Ref = rexi:cast(N, {fabric_rpc, reduce_view, [Name,DDoc,VName,Args]}), Shard#shard{ref = Ref} end, fabric_view:get_shards(DbName, Args)), RexiMon = fabric_util:create_monitors(Workers), - #view_query_args{limit = Limit, skip = Skip} = Args, + #mrargs{limit = Limit, skip = Skip} = Args, OsProc = case os_proc_needed(RedSrc) of true -> couch_query_servers:get_os_process(Lang); _ -> nil @@ -43,7 +44,7 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) -> query_args = Args, callback = Callback, counters = fabric_dict:init(Workers, 0), - keys = Args#view_query_args.keys, + keys = Args#mrargs.keys, skip = Skip, limit = Limit, lang = Lang,
