From 17b04c04c6004725f6115f7b4592d19eba4cda89 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Tue, 16 Dec 2008 20:15:43 +0000 Subject: remove couch_ft_query git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@727126 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/Makefile.am | 3 -- src/couchdb/couch.app.tpl.in | 2 - src/couchdb/couch_ft_query.erl | 90 ------------------------------------------ 3 files changed, 95 deletions(-) delete mode 100644 src/couchdb/couch_ft_query.erl (limited to 'src') diff --git a/src/couchdb/Makefile.am b/src/couchdb/Makefile.am index a2099931..9db1539b 100644 --- a/src/couchdb/Makefile.am +++ b/src/couchdb/Makefile.am @@ -53,7 +53,6 @@ source_files = \ couch_httpd_db.erl \ couch_httpd_view.erl \ couch_httpd_misc_handlers.erl \ - couch_ft_query.erl \ couch_key_tree.erl \ couch_log.erl \ couch_query_servers.erl \ @@ -80,7 +79,6 @@ compiled_files = \ couch_doc.beam \ couch_event_sup.beam \ couch_file.beam \ - couch_ft_query.beam \ couch_httpd.beam \ couch_httpd_db.beam \ couch_httpd_view.beam \ @@ -116,7 +114,6 @@ compiled_files = \ # couch_doc.html \ # couch_event_sup.html \ # couch_file.html \ -# couch_ft_query.html \ # couch_httpd.html \ # couch_key_tree.html \ # couch_log.html \ diff --git a/src/couchdb/couch.app.tpl.in b/src/couchdb/couch.app.tpl.in index 8611df4b..3b1ea02f 100644 --- a/src/couchdb/couch.app.tpl.in +++ b/src/couchdb/couch.app.tpl.in @@ -17,13 +17,11 @@ couch_event_sup, couch_db_update_notifier, couch_db_update_notifier_sup, - couch_ft_query, couch_log, couch_rep]}, {registered,[couch_server, couch_server_sup, couch_view, couch_query_servers, - couch_ft_query, couch_db_update_notifier_sup]}, {applications,[kernel,stdlib,crypto,inets,mochiweb]}]}. diff --git a/src/couchdb/couch_ft_query.erl b/src/couchdb/couch_ft_query.erl deleted file mode 100644 index 49cc374f..00000000 --- a/src/couchdb/couch_ft_query.erl +++ /dev/null @@ -1,90 +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. - --module(couch_ft_query). --behaviour(gen_server). - --export([start_link/0, execute/2]). - --export([init/1, terminate/2, handle_call/3, handle_cast/2, handle_info/2,code_change/3, stop/0]). - -start_link() -> - gen_server:start_link({local, couch_ft_query}, couch_ft_query, [], []). - -stop() -> - exit(whereis(couch_ft_query), close). - -execute(DatabaseName, QueryString) -> - gen_server:call(couch_ft_query, {ft_query, DatabaseName, QueryString}). - -init([]) -> - ok = couch_config:register( - fun("search", "query_server") -> - ?MODULE:stop() - end), - - case couch_config:get("search", "query_server", none) of - none -> - {ok, none}; - QueryExec -> - Port = open_port({spawn, QueryExec}, [{line, 1000}, exit_status, hide]), - {ok, Port} - end. - -terminate(_Reason, _Server) -> - ok. - -handle_call({ft_query, _Database, _QueryText}, _From, none) -> - {reply, {error, no_full_test_query_specified_in_config}, none}; -handle_call({ft_query, Database, QueryText}, _From, Port) -> - % send the database name - true = port_command(Port, Database ++ "\n"), - true = port_command(Port, QueryText ++ "\n"), - case get_line(Port) of - "ok" -> - DocIds = read_query_results(Port, []), - {reply, {ok, DocIds}, Port}; - "error" -> - ErrorId = get_line(Port), - ErrorMsg = get_line(Port), - {reply, {list_to_atom(ErrorId), ErrorMsg}, Port} - end. - -read_query_results(Port, Acc) -> - case get_line(Port) of - "" -> % line by itself means all done - lists:reverse(Acc); - DocId -> - Score = get_line(Port), - read_query_results(Port, [{DocId, Score} | Acc]) - end. - - -get_line(Port) -> - receive - {Port, {data, {eol, Line}}} -> - Line; - % would love to use ?ERR_HANDLE here, but edoc doesn't like it. - % TODO: find a way to skip that. - {Port, {exit_status, Status}} -> {stop, {unknown_error, Status}, {unknown_error, Status}, Port} - end. - -handle_cast(_Whatever, State) -> - {noreply, State}. - -handle_info({Port, {exit_status, Status}}, Port) -> - {stop, {os_process_exited, Status}, Port}; -handle_info(_Whatever, State) -> - {noreply, State}. - -code_change(_OldVsn, State, _Extra) -> - {ok, State}. -- cgit v1.2.3