couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Sinclair-Day <>
Subject Re: Scalability of _changes api?
Date Sat, 07 Aug 2010 19:54:09 GMT
On 8/7/10 at 7:37 AM, (Sivan Greenberg) wrote:

>As I am also using a JS filter and fear the performance and load
>consequences, how does one go about writing an erlang filter?

I can't claim it to be idiomatic Erlang, but this is the one I 
am working on that accepts query argument from the client 
opening the change feed.

fun({Doc}, {Req}) ->
     {Query} = couch_util:get_value(<<"query">>, Req),
     ExcludedServer = couch_util:get_value(<<"excludeServer">>, Query),
     case {couch_util:get_value(<<"docType">>, Doc), 
couch_util:get_value(<<"updatedOnServer">>, Doc)} of
         {<<"CS_MANIFEST">>, null} ->
             CreatedOnServer = 
couch_util:get_value(<<"createdOnServer">>, Doc),
             CreatedOnServer =/= ExcludedServer;
         {<<"CS_MANIFEST">>, undefined} ->
         {<<CS_MANIFEST">>, UpdatedOnServer} ->
             UpdatedOnServer =/= ExcludedServer;
         _ ->

BTW, since strings are represented as Binaries (<<>> syntax), 
string manipulation in Erlang map-reduce and filter functions is 
easy with Erlang's BIFs that manipulate binaries, like split_binary().


View raw message