diff options
author | Damien F. Katz <damien@apache.org> | 2008-12-22 20:35:50 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-12-22 20:35:50 +0000 |
commit | c823bd2e8b3990b5c55dde54705d6866ad1eda4f (patch) | |
tree | 4be1ffa83f983e36038841f8b25812f2cfe6d482 /src/couchdb/couch_httpd_view.erl | |
parent | 112e286f3c0727caf6f6c96caa2ba40f31552ac7 (diff) |
Fix for leaked file handles when not explicitly closed, added file stats code for checking for leaked file handles, and some refactoring of the view api.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@728764 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_view.erl')
-rw-r--r-- | src/couchdb/couch_httpd_view.erl | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index 13842149..35203ced 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -26,21 +26,20 @@ design_doc_view(Req, Db, Id, ViewName, Keys) -> update = Update, reduce = Reduce } = QueryArgs = parse_view_query(Req, Keys), - case couch_view:get_map_view({couch_db:name(Db), - <<"_design/", Id/binary>>, ViewName, Update}) of + DesignId = <<"_design/", Id/binary>>, + case couch_view:get_map_view(Db, DesignId, ViewName, Update) of {ok, View} -> output_map_view(Req, View, Db, QueryArgs, Keys); {not_found, Reason} -> - case couch_view:get_reduce_view({couch_db:name(Db), - <<"_design/", Id/binary>>, ViewName}) of - {ok, View} -> + case couch_view:get_reduce_view(Db, DesignId, ViewName, Update) of + {ok, ReduceView} -> parse_view_query(Req, Keys, true), % just for validation case Reduce of false -> - {reduce, _N, _Lang, MapView} = View, + MapView = couch_view:extract_map_view(ReduceView), output_map_view(Req, MapView, Db, QueryArgs, Keys); _ -> - output_reduce_view(Req, View, QueryArgs, Keys) + output_reduce_view(Req, ReduceView, QueryArgs, Keys) end; _ -> throw({not_found, Reason}) @@ -72,11 +71,11 @@ handle_temp_view_req(#httpd{method='POST'}=Req, Db) -> Keys = proplists:get_value(<<"keys">>, Props, nil), case proplists:get_value(<<"reduce">>, Props, null) of null -> - {ok, View} = couch_view:get_map_view({temp, couch_db:name(Db), Language, MapSrc}), + {ok, View} = couch_view:get_temp_map_view(Db, Language, MapSrc), output_map_view(Req, View, Db, QueryArgs, Keys); RedSrc -> - {ok, View} = couch_view:get_reduce_view( - {temp, couch_db:name(Db), Language, MapSrc, RedSrc}), + {ok, View} = couch_view:get_temp_reduce_view(Db, Language, MapSrc, + RedSrc), output_reduce_view(Req, View, QueryArgs, Keys) end; |