summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_query_servers.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-07-20 04:11:36 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-07-20 04:11:36 +0000
commit46bf4b727f0fae37b017f194983122c50d3f34e5 (patch)
tree658da02543e8f53388d6ea427afa3e6265d5254d /src/couchdb/couch_query_servers.erl
parentc3175ec3b2809a553cd0f45bfa39ca573676f842 (diff)
Initial checkin of _changes filters. The prime weak-spot for this approach is that it maintains an OS-process per connected filtered _changes consumer. I'm pretty sure we'll be able to work around this without changing the API, but it'll involve a lot of OS-process bookkeeping. Those enhancements should generally improve show & list performance as well. Punting on them for now, first wanted to get _changes filters implemented so people could give feedback.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@795687 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_query_servers.erl')
-rw-r--r--src/couchdb/couch_query_servers.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl
index 02018e33..1d452796 100644
--- a/src/couchdb/couch_query_servers.erl
+++ b/src/couchdb/couch_query_servers.erl
@@ -20,6 +20,7 @@
-export([reduce/3, rereduce/3,validate_doc_update/5]).
-export([render_doc_show/6, start_view_list/2,
render_list_head/4, render_list_row/3, render_list_tail/1]).
+-export([start_filter/2, filter_doc/4, end_filter/1]).
% -export([test/0]).
-include("couch_db.hrl").
@@ -211,8 +212,22 @@ render_list_tail({Lang, Pid}) ->
ok = ret_os_process(Lang, Pid),
JsonResp.
+start_filter(Lang, FilterSrc) ->
+ Pid = get_os_process(Lang),
+ true = couch_os_process:prompt(Pid, [<<"add_fun">>, FilterSrc]),
+ {ok, {Lang, Pid}}.
+filter_doc({_Lang, Pid}, Doc, Req, Db) ->
+ JsonReq = couch_httpd_external:json_req_obj(Req, Db),
+ JsonDoc = couch_doc:to_json_obj(Doc, [revs]),
+ JsonCtx = couch_util:json_user_ctx(Db),
+ [true, [Pass]] = couch_os_process:prompt(Pid,
+ [<<"filter">>, [JsonDoc], JsonReq, JsonCtx]),
+ {ok, Pass}.
+end_filter({Lang, Pid}) ->
+ ok = ret_os_process(Lang, Pid).
+
init([]) ->