The point of shows and lists? OK. So I spent a lot of time learning Erlang. Now that I got shows to work, I am noticing that the performance is still many times slower than getting a document straight from Couch and processing it in Java. Javascript shows are unusable when you're expecting to scale to significant numbers. Here's what I get: Javascript: 60 tx/sec Erlang: 300 tx/sec No show: 1000 tx/sec No show + Java middle tier: 800 tx/sec
I wish I knew about this before. Thomas On Oct 8, 2011 8:13 AM, "Thomas Van de Velde" <[email protected]> wrote: > So is this possible? I found no way to access the data sent from within > the Fun = fun({Row}, _) -> function outside that function block. FoldRows > seems to return whatever was sent within the rows iterator directly to the > client. How can I capture that output so it can be modified to construct my > own JSON object? Thanks! > > On Fri, Oct 7, 2011 at 10:49 AM, Thomas Van de Velde <[email protected] > > wrote: > >> Hi, >> >> I made great progress converting Javascript shows to Erlang. I need some >> help with lists in Erlang. I have a JSON document that has pointers to other >> documents (with include_docs=true). Within the list, I construct a new JSON >> document that aggregates information I pulled from the documents that were >> referenced. Below you'll find the Javascript implementation. I am having >> trouble reproducing this in Erlang. >> >> This is what I have in Javascript: >> >> function(head, req) { >> >> start({ >> "headers" : { >> "Content-Type" : "text/plain" >> } >> }); >> >> var page = []; >> >> while( row = getRow()) { >> var module = row.value.module; >> var desc = row.doc.desc; >> var title = row.doc.title; >> var module = { >> "module" : module, >> "desc" : desc, >> "title" : title >> }; >> page.push(module); >> } >> send(JSON.stringify(page)); >> >> } >> >> I am starting from what's in the unit test: >> >> %% Page generator (from Futon unit test) >> fun(Head, {Req}) -> >> Send(<<"head">>), >> Fun = fun({Row}, _) -> >> Val = couch_util:get_value(<<"value">>, Row, -1), >> Send(list_to_binary(integer_to_list(Val))), >> {ok, nil} >> end, >> {ok, _} = FoldRows(Fun, nil), >> <<"tail">> >> end. >> >> In a show I was able to construct a new JSON document and then return it >> with: >> >> {[{<<"code">>, 200}, {<<"headers">>, {[]}}, {<<"json">>, MyDoc}]} >> >> How can I do something similar where I iterate through the rows, take some >> data from each row and then send the result as a single JSON document? >> >> Thank you! >> >> Thomas >> > >
