Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C55DBDBA0 for ; Sat, 22 Sep 2012 19:24:56 +0000 (UTC) Received: (qmail 17624 invoked by uid 500); 22 Sep 2012 19:24:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 17596 invoked by uid 500); 22 Sep 2012 19:24:55 -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 17588 invoked by uid 99); 22 Sep 2012 19:24:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Sep 2012 19:24:55 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mainerror@gmail.com designates 209.85.217.180 as permitted sender) Received: from [209.85.217.180] (HELO mail-lb0-f180.google.com) (209.85.217.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Sep 2012 19:24:50 +0000 Received: by lbcs4 with SMTP id s4so3029282lbc.11 for ; Sat, 22 Sep 2012 12:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GStMv1o2R1pOUSxiC8MhWG7ZF8vYERwCuMTRkZHM2wk=; b=QNF6TvzKD2eLjoIUz9Ky5RQ9zTO9PEoLaeS4Myi6VbqyVVU2CGUIgUItT98BxRJlL8 zlnpP1DO4INLIILI4ozBl9ucOx8ij/lAFwPEWs77zuak7vpDHXeJzMs7FYDMMTotyrGt zjXsj2CxMZa4Y8oro35eBi0S8HENpNB1YnJnIllNmStuE2hulwlenKrDGh7NloHQRbcw 8NE/h9ZPLyWW/Ncw+8CV4f+s6PxuWw7ApJdBqyiV13RBG+wnYz21yz0TW6pfBIzDkZfO SuwwdcUHfLsDSVGRLOpTqQoSylXE1KvWru8WkI+CoWyWJ4IMcgtq5qTD7P4llEOhDl/g KK2Q== MIME-Version: 1.0 Received: by 10.152.124.18 with SMTP id me18mr7149151lab.6.1348341869045; Sat, 22 Sep 2012 12:24:29 -0700 (PDT) Received: by 10.114.5.99 with HTTP; Sat, 22 Sep 2012 12:24:28 -0700 (PDT) In-Reply-To: <20120922222314.68ff1a0f@svilendobrev.com> References: <20120922200519.52f9176f@eee-az> <20120922215736.78b25d63@svilendobrev.com> <20120922222314.68ff1a0f@svilendobrev.com> Date: Sat, 22 Sep 2012 21:24:28 +0200 Message-ID: Subject: Re: what's the order of docs/keys going into reduce func? From: Octavian Damiean To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=f46d0437452123e6e904ca4f4ea8 X-Virus-Checked: Checked by ClamAV on apache.org --f46d0437452123e6e904ca4f4ea8 Content-Type: text/plain; charset=UTF-8 I don't understand a thing, sorry. You might have to rephrase it. On Sat, Sep 22, 2012 at 9:23 PM, svilen wrote: > > > no, yours is just a simple filter, and it will always have them all > > > as they all start from being off. > > > > I am having trouble understanding this. What do you mean by "simple > > filter"? A view is a view, not a filter. Once the view is set up it > > will always be up-to-date. > > take 2 steps back and reread my question from start. the important > notions are "multiple values" with "same-keys" and their "current > state-per-key". that is what i want. > > svil > > > On Sat, Sep 22, 2012 at 11:57 AM, svilen wrote: > > > > > no, yours is just a simple filter, and it will always have them all > > > as they all start from being off. > > > > > > and it is somewhat simplified example. The original thing has > > > multiple states, and i want the last/current one - whatever it is. > > > > > > say, i want to reduce things like assigning ( a=1, a=2, b=1, b=2, > > > a=3 ) into flat last-state ( a=3, b=2 ) > > > > > > how to do that? > > > > > > svil > > > > > > > > > On Sat, 22 Sep 2012 11:43:14 -0700 > > > Mark Hahn wrote: > > > > > > > > i want a view for all lamps that the currently off. > > > > > > > > You view is wrong. You should only emit when the lamp is off. > > > > > > > > Also, you should always return a value in reduce. Returning null > > > > will screw things up. > > > > > > > > I would start by fixing these problems and then go from there. > > > > > > > > > > > > On Sat, Sep 22, 2012 at 3:05 AM, svilen > > > > wrote: > > > > > > > > > say i have some lamp status monitoring records, i.e. > > > > > > > > > > { "seq": 1, "name": "a", }, > > > > > { "seq": 2, "name": "b", }, > > > > > { "seq": 2, "name": "a", "on": true}, > > > > > { "seq": 3, "name": "a", }, > > > > > { "seq": 7, "name": "a", "on": true}, > > > > > > > > > > ... > > > > > > > > > > where default state is off, and when on, there's extra bool > > > > > attribute for it. Records are sequenced (in time) by some .seq > > > > > param. And there's many other here-irrelevant attributes. > > > > > > > > > > say i want a view for all lamps that the currently off. > > > > > > > > > > so, something like: > > > > > > > > > > map_func: function( doc) { > > > > > if (doc.type == 'lamp') emit( [doc.name, doc.seq], doc ); > > > > > } > > > > > > > > > > reduce_func: function( keys, values, rereduce) { > > > > > var v = values[ values.length-1]; > > > > > if (v == null || v.on) return null; > > > > > return v; > > > > > } > > > > > > > > > > always used with group_level= 1 > > > > > > > > > > but i get the very first state instead of very last state... > > > > > > > > > > and in the debug-log, i see that the keys passed to reduce are > > > > > reversed! > > > > > > > > > > so i have to use descending=True, and only then it works > > > > > correctly. > > > > > > > > > > the question is, is this expected, or is the default order > > > > > defined somewhere else, or what? > > > > > > > > > > ciao > > > > > svil > > > > > > > > > --f46d0437452123e6e904ca4f4ea8--