> > 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> > > > 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 > > > > > >
