couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Barker <norman.bar...@gmail.com>
Subject Re: Erlang views
Date Fri, 20 Nov 2009 14:26:45 GMT
On Friday, November 20, 2009, Paul Davis <paul.joseph.davis@gmail.com> wrote:
> On Thu, Nov 19, 2009 at 6:15 PM, Michael McCaffrey
> <mmccaffrey@ittvis.com> wrote:
>> Playing around with erlang views and I'm trying to spawn the Emit.
>>
>>
>>
>> I see the Emit is defined in couch_native_process but can't get the
>> spawn to work.
>>
>>
>>
>> Tried spawn(erlang, Emit,["A',"B"]),  spawn(couch_native_process, Emit,
>> ["A","B"]), etc.
>>
>>
>>
>> Get errors like this.
>>
>>   {badarg,
>>
>>       [{erlang,spawn,
>>
>>            [erlang,
>>
>>             #Fun<couch_native_process.5.68659142>,
>>
>>             [<<"A">>,<<"B">>]]},
>>
>>
>>
>> Anyone know the proper syntax?
>>
>>
>>
>> Thanks
>>
>>
>
> You really shouldn't be spawning here. Unless you pull some acrobatics
> to make sure and block the function and wait for all spawns to return,
> the function calling your views is not setup to expect asynchronous
> results. view functions are expected to behave like functions that are
> passed to lists:fold etc.
>
> HTH,
> Paul Davis
>
if a view is parsing nested json then spawn is useful when traversing
each branch of the json tree. I agree that you need to collect the
results of spawn though and then emit. Being able to do this in
parallel is a nice feature of erlang views.

Norman

Mime
View raw message