Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 44036 invoked from network); 20 Nov 2009 14:27:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Nov 2009 14:27:18 -0000 Received: (qmail 34670 invoked by uid 500); 20 Nov 2009 14:27:16 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 34608 invoked by uid 500); 20 Nov 2009 14:27:16 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 34598 invoked by uid 99); 20 Nov 2009 14:27:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Nov 2009 14:27:16 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of norman.barker@gmail.com designates 209.85.217.211 as permitted sender) Received: from [209.85.217.211] (HELO mail-gx0-f211.google.com) (209.85.217.211) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Nov 2009 14:27:08 +0000 Received: by gxk3 with SMTP id 3so3455286gxk.15 for ; Fri, 20 Nov 2009 06:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=+TzCWu2D0pH1AwUxpBFdMtVSlYpEhEn0Hy/70dUq1oU=; b=DmgUukb7S12WAlSGwNEg4PDPCvLLwOJdbmOGrZJJ1D69vW2h6vFwJtQ8WAqPXYSNLd 6ffYiJhr3PmRt6OPinzLiv652Cjyr6s13UAcxT2ax/YQ/I/sMaQ9/f5MwNFaBoKe7qnA M4SfR+V53yTcA4Lp8szbtlKuxhy84hHfr1be8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=VbxNWL/1+98zgdQxP6hHjY30mdJ0djQ90YWX+WxN5HDDfZNHvIk7UBRMmehtjAxwVP zFkAaUno1B8zCCL2VTV1PZrMKP9NRTYB1Mt/87/hwzT6k1k7/0vvy0etg8kAYz9V6/YI uQbwk/6aAumdITsF6he7xXyoKtp3MNp47koUc= MIME-Version: 1.0 Received: by 10.150.43.37 with SMTP id q37mr2727590ybq.233.1258727205428; Fri, 20 Nov 2009 06:26:45 -0800 (PST) In-Reply-To: References: Date: Fri, 20 Nov 2009 07:26:45 -0700 Message-ID: Subject: Re: Erlang views From: Norman Barker To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Friday, November 20, 2009, Paul Davis wrot= e: > On Thu, Nov 19, 2009 at 6:15 PM, Michael McCaffrey > 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"]), =A0spawn(couch_native_process, Emit= , >> ["A","B"]), etc. >> >> >> >> Get errors like this. >> >> =A0 {badarg, >> >> =A0 =A0 =A0 [{erlang,spawn, >> >> =A0 =A0 =A0 =A0 =A0 =A0[erlang, >> >> =A0 =A0 =A0 =A0 =A0 =A0 #Fun, >> >> =A0 =A0 =A0 =A0 =A0 =A0 [<<"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