couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: Groups of one
Date Mon, 24 Aug 2009 20:23:36 GMT
On Sun, Aug 23, 2009 at 1:13 AM, Brian Candler<B.Candler@pobox.com> wrote:
> Quick question for someone who knows the code well:
>
> When doing a grouped reduce view, would it be easy to detect the case where
> a group consists of exactly one key?  In that case, would it also be easy to
> add "id" to the result row like a normal view, and possibly also "doc" if
> include_docs=true were specified?

I think it would *not* be easy. By the time the reduce has been run,
the context is lost.

I'd handle this by including docid in the value of my map view, and
then making it part of the reduce return value, if and only if there
is just one docid in the incoming values. Of course that won't solve
include_docs but it will make it easy to detect the single-doc
condition.

Chris

>
> (I'm doing this logic externally at the moment)
>
> Thanks,
>
> Brian.
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Mime
View raw message