incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: Arguments for Reduce function
Date Wed, 17 Dec 2008 17:05:44 GMT
Raj,

On Wed, Dec 17, 2008 at 10:43 AM, Rajkumar S <rajkumars@gmail.com> wrote:
> Hi,
>
> I have a (simplified) reduce function like
>
>
> function(key,values){
>    var a,b;
>        for (var i=0; i< values.length; ++i) {
>            if (values[i] < 6){
>                a++;
>            } else {
>                b++;
>            }
>        }
>    }
>    return [values.length,a,b];
> }
>
> The value 6 here is hard coded, is it possible to pass this via some
> sort of arguments?

Unfortunately, no. And this isn't even a feature that *could* be
implemented. In order to provide the ability for Map/Reduce views to
be computed incrementally, it must be guranteed that given identical
input, the output must also be identical. The reduce also needs to
account for consuming it's own output and produce exactly the same
output for a given input.

Also how can I retrieve all results of a view ?

If you mean access a map in a view that also specifies a reduce
function, there's a ?reduce=false query string parameter that will do
that.

>
> Thanks and regards,
>
> raj
>

HTH,
Paul Davis

Mime
View raw message