You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Vladislav Ponomarev <po...@gmail.com> on 2012/11/06 13:55:57 UTC

Any sort order guarantee for key (value) argument of CouchDB reduce function?

Hello,

Per CouchDB guide, the reduce function signature looks like this:

function (key, values, rereduce) {
    return ...; // some calculations happen here
}

where the definition of first arguments is as follows:

>
> when rereduce is false, then:
>
>    - key will be an array whose elements are arrays of the form [key,id],
>    where key is a key emitted by the map function and id is that of the
>    document from which the key was generated.
>    - values will be an array of the values emitted for the respective
>    elements in keys.
>
>
My question is: when rereduce is false, are there any guarantees regarding
the order of key (or values) array elements? My gut feel (based on Reduce
vs Rereduce chapter) is that keys, and respectively values, should be
ordered, but I do not see any direct confirmation.

>
Any ideas? Thank you!

Re: Any sort order guarantee for key (value) argument of CouchDB reduce function?

Posted by Vladislav Ponomarev <po...@gmail.com>.
Thank you Paul.

This is odd to me, but I'll live with that :-)

On Tue, Nov 6, 2012 at 5:05 PM, Paul J Davis <pa...@gmail.com>wrote:

> No, there aren't any guarantees. And rereduce can end up getting passed
> some surprising (to me when I tried relying on ordering at least) sets of
> keys.
>
> On Nov 6, 2012, at 1:55 PM, Vladislav Ponomarev <po...@gmail.com>
> wrote:
>
> > Hello,
> >
> > Per CouchDB guide, the reduce function signature looks like this:
> >
> > function (key, values, rereduce) {
> >    return ...; // some calculations happen here
> > }
> >
> > where the definition of first arguments is as follows:
> >
> >>
> >> when rereduce is false, then:
> >>
> >>   - key will be an array whose elements are arrays of the form [key,id],
> >>   where key is a key emitted by the map function and id is that of the
> >>   document from which the key was generated.
> >>   - values will be an array of the values emitted for the respective
> >>   elements in keys.
> > My question is: when rereduce is false, are there any guarantees
> regarding
> > the order of key (or values) array elements? My gut feel (based on Reduce
> > vs Rereduce chapter) is that keys, and respectively values, should be
> > ordered, but I do not see any direct confirmation.
> >
> > Any ideas? Thank you!
>

Re: Any sort order guarantee for key (value) argument of CouchDB reduce function?

Posted by Paul J Davis <pa...@gmail.com>.
No, there aren't any guarantees. And rereduce can end up getting passed some surprising (to me when I tried relying on ordering at least) sets of keys. 

On Nov 6, 2012, at 1:55 PM, Vladislav Ponomarev <po...@gmail.com> wrote:

> Hello,
> 
> Per CouchDB guide, the reduce function signature looks like this:
> 
> function (key, values, rereduce) {
>    return ...; // some calculations happen here
> }
> 
> where the definition of first arguments is as follows:
> 
>> 
>> when rereduce is false, then:
>> 
>>   - key will be an array whose elements are arrays of the form [key,id],
>>   where key is a key emitted by the map function and id is that of the
>>   document from which the key was generated.
>>   - values will be an array of the values emitted for the respective
>>   elements in keys.
> My question is: when rereduce is false, are there any guarantees regarding
> the order of key (or values) array elements? My gut feel (based on Reduce
> vs Rereduce chapter) is that keys, and respectively values, should be
> ordered, but I do not see any direct confirmation.
> 
> Any ideas? Thank you!

Re: Any sort order guarantee for key (value) argument of CouchDB reduce function?

Posted by svilen <az...@svilendobrev.com>.
no, see reponses to my thread "what's the order of docs/keys going into
reduce func?" from 22.09.

for small sets, it's reversed but that seems just a local consequence of
some algo.

ciao
svilen

On Tue, 6 Nov 2012 16:55:57 +0400
Vladislav Ponomarev <po...@gmail.com> wrote:

> Hello,
> 
> Per CouchDB guide, the reduce function signature looks like this:
> 
> function (key, values, rereduce) {
>     return ...; // some calculations happen here
> }
> 
> where the definition of first arguments is as follows:
> 
> >
> > when rereduce is false, then:
> >
> >    - key will be an array whose elements are arrays of the form
> > [key,id], where key is a key emitted by the map function and id is
> > that of the document from which the key was generated.
> >    - values will be an array of the values emitted for the
> > respective elements in keys.
> >
> >
> My question is: when rereduce is false, are there any guarantees
> regarding the order of key (or values) array elements? My gut feel
> (based on Reduce vs Rereduce chapter) is that keys, and respectively
> values, should be ordered, but I do not see any direct confirmation.
> 
> >
> Any ideas? Thank you!