From user-return-22212-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sat Sep 22 19:09:39 2012 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 6D565D553 for ; Sat, 22 Sep 2012 19:09:39 +0000 (UTC) Received: (qmail 88587 invoked by uid 500); 22 Sep 2012 19:09:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 88448 invoked by uid 500); 22 Sep 2012 19:09:37 -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 88440 invoked by uid 99); 22 Sep 2012 19:09:37 -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:09:37 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) 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:09:32 +0000 Received: by lbcs4 with SMTP id s4so3021948lbc.11 for ; Sat, 22 Sep 2012 12:09:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:from:date :message-id:subject:to:content-type:x-gm-message-state; bh=baHVhJmZSlYcabJG64VJ9/OqpcZv0QkChxVVVxgqCK8=; b=YhOiG4igAgp4TmWulXnIXoJKXyZeoj+vwCVxRvfwIGN2ECs0YCOCVAN+DvjbqAaHOT 7olAZtMOl9daEV3J4X7lsKaKKvPo873b9SeA+9JFerL3rXIt0XFAFCElcYlI4EFcIss0 XF9wp4NoioMP58ZYyAnL0CjAztDYilQBYLL/7pUIIzD90eOJKL4qsEwPjHpn6Jp9HO3B b4q6SOf4PgrHQGVPZEtW6kFF39amXdKXFU7wEdkmvGWqKJ3GKL2N924T2DwzyD093p2W JjG9CQGTeGVSWfFjUSVErI+XL6v+sH6inxBa0OY3Vzg+zkKHOxl9JsbsT/XOmV5P8HOv zWzA== Received: by 10.112.103.71 with SMTP id fu7mr2728838lbb.21.1348340950460; Sat, 22 Sep 2012 12:09:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.74.196 with HTTP; Sat, 22 Sep 2012 12:08:50 -0700 (PDT) X-Originating-IP: [68.5.117.177] In-Reply-To: <20120922215736.78b25d63@svilendobrev.com> References: <20120922200519.52f9176f@eee-az> <20120922215736.78b25d63@svilendobrev.com> From: Mark Hahn Date: Sat, 22 Sep 2012 12:08:50 -0700 Message-ID: Subject: Re: what's the order of docs/keys going into reduce func? To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=bcaec55553f2636a5a04ca4f1725 X-Gm-Message-State: ALoCoQkEjy41O5H+lYpMsNa+yjxLjU6g2Ca+mdkseMAtXm6vqVyZbCiK0O2HisZztphUHsTnZNAY X-Virus-Checked: Checked by ClamAV on apache.org --bcaec55553f2636a5a04ca4f1725 Content-Type: text/plain; charset=ISO-8859-1 > 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. 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 > > > > --bcaec55553f2636a5a04ca4f1725--