incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kowsik <kow...@gmail.com>
Subject Re: Reducing to unique values...
Date Fri, 27 Feb 2009 22:27:02 GMT
With the second solution, I would end up with something like this (after reduce)

{ key: ["a", "one"], value: 3 }
{ key: ["a", "two"], value: 1 }
{ key: ["b", "three"], value: 2 }

So if I want to find all the unique values for "a", I use

startkey=["a"]&endkey=["a\u9999"] and then parse key[1] to get my
unique values. A little ugly, but works.

K.

On Fri, Feb 27, 2009 at 2:22 PM, David Van Couvering
<david.vancouvering@gmail.com> wrote:
> I would hesitate uniquing on the client side as you are as a result shipping
> more data across the network.  I don't fully grok your other solution, but
> in general I would try to reduce the output as much as possible when
> building the view and then ship just what you need over to the client.
>
> David
>
> On Fri, Feb 27, 2009 at 2:13 PM, kowsik <kowsik@gmail.com> wrote:
>
>> First time I'm playing with rereduce and stumped a bit. I got emits like
>> this:
>>
>>    ("a", "one")
>>    ("a", "two")
>>    ("a", "one")
>>    ("a", "one")
>>    ("b", "three")
>>    ("b", "three")
>>
>> What I would like to get at the end of the reduce is this:
>>
>>    { key: "a", value: [ "one", "two" ] }
>>    { key: "b", value: [ "three" ] }
>>
>> I could implement a really simple reduce like this:
>>
>>    reduce(k, v) { return v }
>>
>> and then unique on the client side.
>>
>> Other option is to emit(["a", "one"], 1), reduce to sum and then use
>> startkey/endkey to walk through the unique keys.
>>
>> Is there a better way?
>>
>> Thanks,
>>
>> K.
>>
>
>
>
> --
> David W. Van Couvering
>
> I am looking for a senior position working on server-side Java systems.
>  Feel free to contact me if you know of any opportunities.
>
> http://www.linkedin.com/in/davidvc
> http://davidvancouvering.blogspot.com
> http://twitter.com/dcouvering
>

Mime
View raw message