Permalink
Browse files

removed legacy temp_view code

  • Loading branch information...
1 parent 2d0ed2b commit 379aedd77c7956a31666b8e285179391f8d05982 Robert Dionne committed Nov 24, 2010
View
@@ -6,6 +6,7 @@ erl_crash.dump
# building
apps/*/ebin/
+deps
rel/dbcore
rel/bigcouch.config
rel/overlay.config
@@ -23,7 +24,11 @@ couchjs/config.log
@abs_top_builddir@/
apps/couch/test/temp*
apps/couch/test/etap/
+!apps/couch/test/etap/*.t
# dev
rel/dev*
-rel/tmpdata
+rel/tmpdata
+
+# OS X
+.DS_Store
@@ -13,7 +13,7 @@
-module(couch_httpd_view).
-include("couch_db.hrl").
--export([handle_view_req/3,handle_temp_view_req/2]).
+-export([handle_view_req/3]).
-export([get_stale_type/1, get_reduce_type/1, parse_view_params/3]).
-export([make_view_fold_fun/7, finish_view_fold/4, finish_view_fold/5, view_row_obj/3]).
@@ -77,36 +77,6 @@ handle_view_req(#httpd{method='POST',
handle_view_req(Req, _Db, _DDoc) ->
send_method_not_allowed(Req, "GET,POST,HEAD").
-handle_temp_view_req(#httpd{method='POST'}=Req, Db) ->
- couch_httpd:validate_ctype(Req, "application/json"),
- ok = couch_db:check_is_admin(Db),
- couch_stats_collector:increment({httpd, temporary_view_reads}),
- {Props} = couch_httpd:json_body_obj(Req),
- Language = couch_util:get_value(<<"language">>, Props, <<"javascript">>),
- {DesignOptions} = couch_util:get_value(<<"options">>, Props, {[]}),
- MapSrc = couch_util:get_value(<<"map">>, Props),
- Keys = couch_util:get_value(<<"keys">>, Props, nil),
- Reduce = get_reduce_type(Req),
- case couch_util:get_value(<<"reduce">>, Props, null) of
- null ->
- QueryArgs = parse_view_params(Req, Keys, map),
- {ok, View, Group} = couch_view:get_temp_map_view(Db, Language,
- DesignOptions, MapSrc),
- output_map_view(Req, View, Group, Db, QueryArgs, Keys);
- _ when Reduce =:= false ->
- QueryArgs = parse_view_params(Req, Keys, red_map),
- {ok, View, Group} = couch_view:get_temp_map_view(Db, Language,
- DesignOptions, MapSrc),
- output_map_view(Req, View, Group, Db, QueryArgs, Keys);
- RedSrc ->
- QueryArgs = parse_view_params(Req, Keys, reduce),
- {ok, View, Group} = couch_view:get_temp_reduce_view(Db, Language,
- DesignOptions, MapSrc, RedSrc),
- output_reduce_view(Req, Db, View, Group, QueryArgs, Keys)
- end;
-
-handle_temp_view_req(Req, _Db) ->
- send_method_not_allowed(Req, "POST").
output_map_view(Req, View, Group, Db, QueryArgs, nil) ->
#view_query_args{
@@ -398,7 +368,7 @@ make_view_fold_fun(Req, QueryArgs, Etag, Db, UpdateSeq, TotalViewCount, HelperFu
#view_query_args{
include_docs = IncludeDocs
} = QueryArgs,
-
+
fun({{Key, DocId}, Value}, OffsetReds,
{AccLimit, AccSkip, Resp, RowFunAcc}) ->
case {AccLimit, AccSkip, Resp} of
@@ -14,11 +14,11 @@
-behaviour(gen_server).
-export([start_link/0,fold/4,less_json/2,less_json_ids/2,expand_dups/2,
- detuple_kvs/2,init/1,terminate/2,handle_call/3,handle_cast/2,handle_info/2,
- code_change/3,get_reduce_view/4,get_temp_reduce_view/5,get_temp_map_view/4,
- get_map_view/4,get_row_count/1,reduce_to_count/1,fold_reduce/4,
- extract_map_view/1,get_group_server/2,get_group_info/2,
- cleanup_index_files/1,config_change/2]).
+ detuple_kvs/2,init/1,terminate/2,handle_call/3,handle_cast/2,
+ handle_info/2,code_change/3,get_reduce_view/4,
+ get_map_view/4,get_row_count/1,reduce_to_count/1,fold_reduce/4,
+ extract_map_view/1,get_group_server/2,get_group_info/2,
+ cleanup_index_files/1,config_change/2]).
-include("couch_db.hrl").
@@ -29,17 +29,6 @@
start_link() ->
gen_server:start_link({local, couch_view}, couch_view, [], []).
-get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
- % make temp group
- % do we need to close this db?
- {ok, _Db, Group} =
- couch_view_group:open_temp_group(DbName, Language, DesignOptions, MapSrc, RedSrc),
- case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
- {ok, Pid} ->
- Pid;
- Error ->
- throw(Error)
- end.
get_group_server(DbName, GroupId) ->
% get signature for group
@@ -65,10 +54,6 @@ get_group(Db, GroupId, Stale) ->
get_group_server(couch_db:name(Db), GroupId),
MinUpdateSeq).
-get_temp_group(Db, Language, DesignOptions, MapSrc, RedSrc) ->
- couch_view_group:request_group(
- get_temp_updater(couch_db:name(Db), Language, DesignOptions, MapSrc, RedSrc),
- couch_db:get_update_seq(Db)).
get_group_info(Db, GroupId) ->
couch_view_group:request_group_info(
@@ -109,10 +94,6 @@ get_row_count(#view{btree=Bt}) ->
{ok, {Count, _Reds}} = couch_btree:full_reduce(Bt),
{ok, Count}.
-get_temp_reduce_view(Db, Language, DesignOptions, MapSrc, RedSrc) ->
- {ok, #group{views=[View]}=Group} =
- get_temp_group(Db, Language, DesignOptions, MapSrc, RedSrc),
- {ok, {temp_reduce, View}, Group}.
get_reduce_view(Db, GroupId, Name, Update) ->
@@ -154,12 +135,6 @@ expand_dups([{Key, {dups, Vals}} | Rest], Acc) ->
expand_dups([KV | Rest], Acc) ->
expand_dups(Rest, [KV | Acc]).
-fold_reduce({temp_reduce, #view{btree=Bt}}, Fun, Acc, Options) ->
- WrapperFun = fun({GroupedKey, _}, PartialReds, Acc0) ->
- {_, [Red]} = couch_btree:final_reduce(Bt, PartialReds),
- Fun(GroupedKey, Red, Acc0)
- end,
- couch_btree:fold_reduce(Bt, WrapperFun, Acc, Options);
fold_reduce({reduce, NthRed, Lang, #view{btree=Bt, reduce_funs=RedFuns}}, Fun, Acc, Options) ->
PreResultPadding = lists:duplicate(NthRed - 1, []),
@@ -188,9 +163,6 @@ get_key_pos(Key, [_|Rest], N) ->
get_key_pos(Key, Rest, N+1).
-get_temp_map_view(Db, Language, DesignOptions, Src) ->
- {ok, #group{views=[View]}=Group} = get_temp_group(Db, Language, DesignOptions, Src, []),
- {ok, View, Group}.
get_map_view(Db, GroupId, Name, Stale) ->
case get_group(Db, GroupId, Stale) of
@@ -15,7 +15,7 @@
%% API
-export([start_link/1, request_group/2, request_group_info/1]).
--export([open_db_group/2, open_temp_group/5, design_doc_to_view_group/1,design_root/2]).
+-export([open_db_group/2, design_doc_to_view_group/1,design_root/2]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -417,27 +417,6 @@ open_index_file(compact, RootDir, DbName, GroupSig) ->
Error -> Error
end.
-open_temp_group(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
- case couch_db:open_int(DbName, []) of
- {ok, Db} ->
- View = #view{map_names=[<<"_temp">>],
- id_num=0,
- btree=nil,
- def=MapSrc,
- reduce_funs= if RedSrc==[] -> []; true -> [{<<"_temp">>, RedSrc}] end,
- options=DesignOptions},
-
- {ok, Db, set_view_sig(#group{name = <<"_temp">>, views=[View],
- def_lang=Language, design_options=DesignOptions})};
- Error ->
- Error
- end.
-
-set_view_sig(#group{
- views=Views,
- def_lang=Language,
- design_options=DesignOptions}=G) ->
- G#group{sig=couch_util:md5(term_to_binary({Views, Language, DesignOptions}))}.
open_db_group(DbName, GroupId) ->
FullDbName = mem3_util:extract_db_name(DbName),
@@ -77,7 +77,6 @@ _rexi_calls = {couch_httpd_misc_handlers, handle_rexi_calls_req}
_view_cleanup = {couch_httpd_db, handle_view_cleanup_req}
_compact = {couch_httpd_db, handle_compact_req}
_design = {couch_httpd_db, handle_design_req}
-_temp_view = {couch_httpd_view, handle_temp_view_req}
_changes = {couch_httpd_db, handle_changes_req}
[httpd_design_handlers]

0 comments on commit 379aedd

Please sign in to comment.