Permalink
Browse files

Remove the old view engine.

So long, and thanks for all the fish.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1171150 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent e83352f commit dbeea8f8f5c8e60db929344c2de19ccf2f68fe51 @davisp davisp committed Sep 15, 2011
View
2 Makefile.am
@@ -82,7 +82,7 @@ THANKS.gz: $(top_srcdir)/THANKS
-gzip -9 < $< > $@
check: dev
- $(top_builddir)/test/etap/run test/etap
+ $(top_builddir)/test/etap/run $(top_srcdir)/test/etap
cover: dev
rm -f cover/*.coverdata
View
15 src/couchdb/Makefile.am
@@ -54,8 +54,6 @@ source_files = \
couch_httpd_auth.erl \
couch_httpd_oauth.erl \
couch_httpd_external.erl \
- couch_httpd_show.erl \
- couch_httpd_view.erl \
couch_httpd_misc_handlers.erl \
couch_httpd_proxy.erl \
couch_httpd_replicator.erl \
@@ -85,10 +83,6 @@ source_files = \
couch_task_status.erl \
couch_util.erl \
couch_uuids.erl \
- couch_view.erl \
- couch_view_compactor.erl \
- couch_view_updater.erl \
- couch_view_group.erl \
couch_db_updater.erl \
couch_work_queue.erl \
json_stream_parse.erl
@@ -125,8 +119,6 @@ compiled_files = \
couch_httpd_oauth.beam \
couch_httpd_proxy.beam \
couch_httpd_external.beam \
- couch_httpd_show.beam \
- couch_httpd_view.beam \
couch_httpd_misc_handlers.beam \
couch_httpd_replicator.beam \
couch_httpd_rewrite.beam \
@@ -155,10 +147,6 @@ compiled_files = \
couch_task_status.beam \
couch_util.beam \
couch_uuids.beam \
- couch_view.beam \
- couch_view_compactor.beam \
- couch_view_updater.beam \
- couch_view_group.beam \
couch_db_updater.beam \
couch_work_queue.beam \
json_stream_parse.beam
@@ -190,8 +178,7 @@ compiled_files = \
# couch_server.html \
# couch_server_sup.html \
# couch_stream.html \
-# couch_util.html \
-# couch_view.html
+# couch_util.html
if WINDOWS
couch.app: couch.app.tpl
View
3 src/couchdb/couch.app.tpl.in
@@ -17,8 +17,7 @@
couch_server_sup,
couch_stats_aggregator,
couch_stats_collector,
- couch_task_status,
- couch_view
+ couch_task_status
]},
{mod, {couch_app, [
"%localconfdir%/@defaultini@",
View
2 src/couchdb/couch_changes.erl
@@ -366,7 +366,7 @@ changes_row(Results, DocInfo, Acc) ->
deleted_item(Del) ++ case IncDoc of
true ->
Options = if Conflicts -> [conflicts]; true -> [] end,
- couch_httpd_view:doc_member(Db, DocInfo, Options);
+ couch_util:doc_member(Db, DocInfo, Options);
false ->
[]
end}.
View
2 src/couchdb/couch_compaction_daemon.erl
@@ -224,7 +224,7 @@ db_ddoc_names(Db) ->
maybe_compact_view(DbName, GroupId, Config) ->
DDocId = <<"_design/", GroupId/binary>>,
- case (catch couch_view:get_group_info(DbName, DDocId)) of
+ case (catch couch_mrview:get_info(DbName, DDocId)) of
{ok, GroupInfo} ->
case can_view_compact(Config, DbName, GroupId, GroupInfo) of
true ->
View
35 src/couchdb/couch_db.erl
@@ -301,17 +301,17 @@ sum_tree_sizes(Acc, [T | Rest]) ->
end.
get_design_docs(Db) ->
- {ok, _, Docs} = couch_view:fold(
- #view{btree=by_id_btree(Db)},
- fun(#full_doc_info{deleted = true}, _Reds, AccDocs) ->
- {ok, AccDocs};
- (#full_doc_info{id= <<"_design/",_/binary>>}=FullDocInfo, _Reds, AccDocs) ->
+ FoldFun = skip_deleted(fun
+ (#full_doc_info{deleted = true}, _Reds, Acc) ->
+ {ok, Acc};
+ (#full_doc_info{id= <<"_design/",_/binary>>}=FullDocInfo, _Reds, Acc) ->
{ok, Doc} = open_doc_int(Db, FullDocInfo, [ejson_body]),
- {ok, [Doc | AccDocs]};
- (_, _Reds, AccDocs) ->
- {stop, AccDocs}
- end,
- [], [{start_key, <<"_design/">>}, {end_key_gt, <<"_design0">>}]),
+ {ok, [Doc | Acc]};
+ (_, _Reds, Acc) ->
+ {stop, Acc}
+ end),
+ KeyOpts = [{start_key, <<"_design/">>}, {end_key_gt, <<"_design0">>}],
+ {ok, _, Docs} = couch_btree:fold(by_id_btree(Db), FoldFun, [], KeyOpts),
{ok, Docs}.
check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) ->
@@ -1052,8 +1052,9 @@ enum_docs_since(Db, SinceSeq, InFun, Acc, Options) ->
{ok, enum_docs_since_reduce_to_count(LastReduction), AccOut}.
enum_docs(Db, InFun, InAcc, Options) ->
- {ok, LastReduce, OutAcc} = couch_view:fold(
- #view{btree=by_id_btree(Db)}, InFun, InAcc, Options),
+ FoldFun = skip_deleted(InFun),
+ {ok, LastReduce, OutAcc} = couch_btree:fold(
+ by_id_btree(Db), FoldFun, InAcc, Options),
{ok, enum_docs_reduce_to_count(LastReduce), OutAcc}.
% server functions
@@ -1305,3 +1306,13 @@ by_seq_btree(#db{docinfo_by_seq_btree = BTree, fd = ReaderFd}) ->
by_id_btree(#db{fulldocinfo_by_id_btree = BTree, fd = ReaderFd}) ->
BTree#btree{fd = ReaderFd}.
+
+skip_deleted(FoldFun) ->
+ fun
+ (visit, KV, Reds, Acc) ->
+ FoldFun(KV, Reds, Acc);
+ (traverse, _LK, {Undeleted, _Del, _Size}, Acc) when Undeleted == 0 ->
+ {skip, Acc};
+ (traverse, _, _, Acc) ->
+ {ok, Acc}
+ end.
View
47 src/couchdb/couch_httpd_db.erl
@@ -16,7 +16,7 @@
-export([handle_request/1, handle_compact_req/2, handle_design_req/2,
db_req/2, couch_doc_open/4,handle_changes_req/2,
update_doc_result_to_json/1, update_doc_result_to_json/2,
- handle_design_info_req/3, handle_view_cleanup_req/2]).
+ handle_design_info_req/3]).
-import(couch_httpd,
[send_json/2,send_json/3,send_json/4,send_method_not_allowed/2,
@@ -125,31 +125,24 @@ handle_changes_req1(Req, Db) ->
)
end.
-handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, Db) ->
- ok = couch_db:check_is_admin(Db),
- couch_httpd:validate_ctype(Req, "application/json"),
- {ok, _} = couch_view_compactor:start_compact(DbName, Id),
- send_json(Req, 202, {[{ok, true}]});
-
handle_compact_req(#httpd{method='POST'}=Req, Db) ->
- ok = couch_db:check_is_admin(Db),
- couch_httpd:validate_ctype(Req, "application/json"),
- {ok, _} = couch_db:start_compact(Db),
- send_json(Req, 202, {[{ok, true}]});
+ case Req#httpd.path_parts of
+ [_DbName, <<"_compact">>] ->
+ ok = couch_db:check_is_admin(Db),
+ couch_httpd:validate_ctype(Req, "application/json"),
+ {ok, _} = couch_db:start_compact(Db),
+ send_json(Req, 202, {[{ok, true}]});
+ [_DbName, <<"_compact">>, DesignName | _] ->
+ DesignId = <<"_design/", DesignName/binary>>,
+ DDoc = couch_httpd_db:couch_doc_open(
+ Db, DesignId, nil, [ejson_body]
+ ),
+ couch_mrview_http:handle_compact_req(Req, Db, DDoc)
+ end;
handle_compact_req(Req, _Db) ->
send_method_not_allowed(Req, "POST").
-handle_view_cleanup_req(#httpd{method='POST'}=Req, Db) ->
- % delete unreferenced index files
- ok = couch_db:check_is_admin(Db),
- couch_httpd:validate_ctype(Req, "application/json"),
- ok = couch_view:cleanup_index_files(Db),
- send_json(Req, 202, {[{ok, true}]});
-
-handle_view_cleanup_req(Req, _Db) ->
- send_method_not_allowed(Req, "POST").
-
handle_design_req(#httpd{
path_parts=[_DbName, _Design, DesignName, <<"_",_/binary>> = Action | _Rest],
@@ -171,14 +164,8 @@ handle_design_info_req(#httpd{
path_parts=[_DbName, _Design, DesignName, _]
}=Req, Db, _DDoc) ->
DesignId = <<"_design/", DesignName/binary>>,
- {ok, GroupInfoList} = couch_view:get_group_info(Db, DesignId),
- send_json(Req, 200, {[
- {name, DesignName},
- {view_index, {GroupInfoList}}
- ]});
-
-handle_design_info_req(Req, _Db, _DDoc) ->
- send_method_not_allowed(Req, "GET").
+ DDoc = couch_httpd_db:couch_doc_open(Db, DesignId, nil, [ejson_body]),
+ couch_mrview_http:handle_info_req(Req, Db, DDoc).
create_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
ok = couch_httpd:verify_is_server_admin(Req),
@@ -574,7 +561,7 @@ all_docs_view_row_obj(Db, {_KeyDocId, DocInfo}, true, Conflicts) ->
#doc_info{revs = [#rev_info{deleted = true} | _]} ->
{all_docs_row(DocInfo) ++ [{doc, null}]};
_ ->
- {all_docs_row(DocInfo) ++ couch_httpd_view:doc_member(
+ {all_docs_row(DocInfo) ++ couch_util:doc_member(
Db, DocInfo, if Conflicts -> [conflicts]; true -> [] end)}
end;
all_docs_view_row_obj(_Db, {_KeyDocId, DocInfo}, _IncludeDocs, _Conflicts) ->
View
8 test/etap/001-load.t
@@ -17,7 +17,6 @@
main(_) ->
test_util:init_code_path(),
- etap:plan(50),
Modules = [
couch_auth_cache,
couch_api_wrap,
@@ -44,9 +43,7 @@ main(_) ->
couch_httpd_misc_handlers,
couch_httpd_replicator,
couch_httpd_rewrite,
- couch_httpd_show,
couch_httpd_stats_handlers,
- couch_httpd_view,
couch_key_tree,
couch_log,
couch_os_process,
@@ -65,14 +62,11 @@ main(_) ->
couch_stream,
couch_task_status,
couch_util,
- couch_view,
- couch_view_compactor,
- couch_view_group,
- couch_view_updater,
couch_work_queue,
json_stream_parse
],
+ etap:plan(length(Modules)),
lists:foreach(
fun(Module) ->
etap_can:loaded_ok(
View
2 test/etap/072-cleanup.t
@@ -120,7 +120,7 @@ query_view(DDoc, View) ->
view_cleanup() ->
{ok, Db} = couch_db:open(?TEST_DB, [{user_ctx, ?ADMIN_USER}]),
- couch_view:cleanup_index_files(Db),
+ couch_mrview:cleanup(Db),
couch_db:close(Db).
count_index_files() ->
View
12 test/etap/200-view-group-no-db-leaks.t
@@ -98,33 +98,33 @@ test() ->
query_view(),
check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
+ etap:is(is_process_alive(IndexerPid), true, "view group pid is alive"),
create_new_doc(<<"doc1000">>),
query_view(),
check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
+ etap:is(is_process_alive(IndexerPid), true, "view group pid is alive"),
Ref1 = get_db_ref_counter(),
compact_db(),
check_db_ref_count(),
Ref2 = get_db_ref_counter(),
etap:isnt(Ref1, Ref2, "DB ref counter changed"),
etap:is(false, is_process_alive(Ref1), "old DB ref counter is not alive"),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
+ etap:is(is_process_alive(IndexerPid), true, "view group pid is alive"),
compact_view_group(),
check_db_ref_count(),
Ref3 = get_db_ref_counter(),
etap:is(Ref3, Ref2, "DB ref counter didn't change"),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
+ etap:is(is_process_alive(IndexerPid), true, "view group pid is alive"),
create_new_doc(<<"doc1001">>),
query_view(),
check_db_ref_count(),
- etap:is(is_process_alive(ViewGroup), true, "view group pid is alive"),
+ etap:is(is_process_alive(IndexerPid), true, "view group pid is alive"),
- MonRef = erlang:monitor(process, ViewGroup),
+ MonRef = erlang:monitor(process, IndexerPid),
ok = couch_server:delete(test_db_name(), []),
receive
{'DOWN', MonRef, _, _, _} ->
View
18 test/etap/220-compaction-daemon.t
@@ -163,14 +163,12 @@ populate(DbFrag, ViewFrag, MinFileSize, _, _, _) ->
update() ->
{ok, Db} = couch_db:open_int(test_db_name(), []),
- Docs = lists:map(
- fun(_) ->
- Doc = couch_doc:from_json_obj({[{<<"_id">>, couch_uuids:new()}]}),
- {ok, _} = couch_db:update_docs(Db, [Doc])
- end,
- lists:seq(1, 100)),
- couch_db:close(Db),
- query_view().
+ lists:foreach(fun(_) ->
+ Doc = couch_doc:from_json_obj({[{<<"_id">>, couch_uuids:new()}]}),
+ {ok, _} = couch_db:update_docs(Db, [Doc]),
+ query_view()
+ end, lists:seq(1, 100)),
+ couch_db:close(Db).
db_url() ->
"http://" ++ get(addr) ++ ":" ++ get(port) ++ "/" ++
@@ -199,7 +197,7 @@ get_db_frag() ->
get_view_frag() ->
{ok, Db} = couch_db:open_int(test_db_name(), []),
- {ok, Info} = couch_view:get_group_info(Db, <<"_design/foo">>),
+ {ok, Info} = couch_mrview:get_info(Db, <<"_design/foo">>),
couch_db:close(Db),
FileSize = couch_util:get_value(disk_size, Info),
DataSize = couch_util:get_value(data_size, Info),
@@ -219,7 +217,7 @@ wait_compaction_finished() ->
wait_loop(Parent) ->
{ok, Db} = couch_db:open_int(test_db_name(), []),
{ok, DbInfo} = couch_db:get_db_info(Db),
- {ok, ViewInfo} = couch_view:get_group_info(Db, <<"_design/foo">>),
+ {ok, ViewInfo} = couch_mrview:get_info(Db, <<"_design/foo">>),
couch_db:close(Db),
case (couch_util:get_value(compact_running, ViewInfo) =:= true) orelse
(couch_util:get_value(compact_running, DbInfo) =:= true) of

0 comments on commit dbeea8f

Please sign in to comment.