Return-Path: Delivered-To: apmail-incubator-couchdb-dev-archive@locus.apache.org Received: (qmail 81180 invoked from network); 18 Nov 2008 19:35:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Nov 2008 19:35:55 -0000 Received: (qmail 11128 invoked by uid 500); 18 Nov 2008 19:36:02 -0000 Delivered-To: apmail-incubator-couchdb-dev-archive@incubator.apache.org Received: (qmail 11088 invoked by uid 500); 18 Nov 2008 19:36:02 -0000 Mailing-List: contact couchdb-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-dev@incubator.apache.org Received: (qmail 11077 invoked by uid 99); 18 Nov 2008 19:36:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Nov 2008 11:36:02 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.68.5.15] (HELO relay01.pair.com) (209.68.5.15) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 18 Nov 2008 19:34:40 +0000 Received: (qmail 44407 invoked from network); 18 Nov 2008 19:35:22 -0000 Received: from 96.33.90.152 (HELO ?192.168.1.200?) (96.33.90.152) by relay01.pair.com with SMTP; 18 Nov 2008 19:35:22 -0000 X-pair-Authenticated: 96.33.90.152 Cc: couchdb-dev@incubator.apache.org Message-Id: <53DB0574-D751-4633-AB5C-D66A535B1A6E@apache.org> From: Damien Katz To: couchdb-user@incubator.apache.org In-Reply-To: <492317D5.60300@silencegreys.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: View with incremental counter Date: Tue, 18 Nov 2008 14:35:22 -0500 References: <4922C646.7010802@silencegreys.com> <492317D5.60300@silencegreys.com> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org Spidermonkey's sandboxing capabilities vary release to release. As I recall, we had full sandboxing working with earlier releases, but something changed in 1.7 and we took it out. -Damien On Nov 18, 2008, at 2:30 PM, Jedediah Smith wrote: > > Grasping the concepts involved in map/reduce might end up being a > significant hurdle to CouchDB adoption so I would encourage features > that assist in that regard. Sandboxing might also be necessary to > enforce whatever is ultimately CouchDB's security model. > > Spidermonkey must have sandboxing capabilities if it runs the > javascript for both the Firefox browser and the web pages it loads. > > Paul's case of caching large objects is something to consider (and a > reason my previous email was not strictly correct) but could perhaps > be handled more formally or left to custom view servers. > > Benjamin Nortier wrote: >> Should CouchDB not restrict defining state outside the map function? >> I.e. you should not be able to declare a counter outside the >> function? >> On Tue, Nov 18, 2008 at 1:42 PM, Jedediah Smith >> wrote: >>> You can't maintain a state across calls to map functions in this >>> way. Map >>> functions can be called in any order or in parallel, any number of >>> times on >>> a particular document and in completely separate environments. >>> They should >>> not have any side effects or depend on any outside state. >>> >>> You should read up on Google's MapReduce and maybe functional >>> programming in >>> general in order to understand how CouchDB works. >>> >>> If you just want to number the results of your view, that can be >>> easily done >>> by the calling code. >>> >>> Adam Groves wrote: >>>> Hi, >>>> >>>> I've got the following view: >>>> >>>> count = 0; >>>> function(doc) { >>>> if(doc.type == "document") { >>>> count = count + 1 >>>> emit(doc._id, count); >>>> } >>>> } >>>> >>>> The idea is that I get a list of documents, each having a counter >>>> value which is incremental. I expected the count values to come >>>> out in >>>> order, but that isn't the case: my first few documents have >>>> values of >>>> 62, 61, 22, 19. I'm not quite sure what's going on here - any ideas >>>> how the order is being set here? >>>> >>>> Regards >>>> >>>> Adam Groves >>>>