Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB: map-reduce in Erlang

How can I write map-reduce functions in Erlang for CouchDB? I am sure Erlang is faster than JavaScript.

like image 309
edbond Avatar asked Jul 23 '09 08:07

edbond


2 Answers

pmap(F, L) ->
    Parent = self(),
    Pids = [spawn(fun() ->
                     Parent ! {self(), F(X)}
                  end) || X -> L],
    [receive {Pid, Res} -> Res end || Pid < - Pids].

I believe I did, Bob.

like image 116
Fu. Avatar answered Sep 18 '22 18:09

Fu.


You can do so using erlview, which is within the top ten hits on Google for "couchdb erlang view" and is listed on the CouchDB wiki page for other-language view servers.

like image 31
Jim Puls Avatar answered Sep 18 '22 18:09

Jim Puls