You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Aurélien Bénel <au...@utt.fr> on 2010/03/24 17:34:38 UTC

group_level in reduce function

Hi everyone,

I'm learning how to use CouchDB for a few days and I must say I am thrilled to use it on production servers!
"Thank the makers" :)

At first, I had a rough time understanding how 'rereduce' worked, and how to comply with 'reduce' constraints for a non-trivial algorithm. I changed the specification a bit to be able to do it with an associative and commutative 'reduce' function.

My next step would be to choose a different 'reduce' algorithm depending on 'group_level'. In order to get 'group_level' from the 'reduce' function, I thought about comparing keys in order to determine which level is the same, however it is time-consuming and could be false in particular settings (when there is only one [X,_] per [X] in the 'map' results).

Is there an easier and safer way to get 'group_level' from a 'reduce' function?


Regards,

Aurélien


Re: group_level in reduce function

Posted by Zachary Zolton <za...@gmail.com>.
Yeah, I'd definitely use the _changes feed for this work.

I haven't tried Mikeal Rogers Node.JS-based _changes listener yet, but
it looks pretty cool:
http://www.mikealrogers.com/archives/726

Basically, it looks like you can put _changes handlers into your design doc.

On Thu, Mar 25, 2010 at 3:50 AM, Aurélien Bénel <au...@utt.fr> wrote:
>> Folks who really need to chain map-reduced views have to hand-roll their own solution. This usually involve some scripting to keep a derived database up-to-date with the output of the source database's view.
>
> Hmm. The script would be listening to "_changes", right?
>
> Sorry for the newbie question, but is it possible to store and execute such a custom script in CouchDB so that it can be deployed as easily as views, lists and shows?
>
> Regards,
>
> Aurélien

Re: group_level in reduce function

Posted by Aurélien Bénel <au...@utt.fr>.
> Folks who really need to chain map-reduced views have to hand-roll their own solution. This usually involve some scripting to keep a derived database up-to-date with the output of the source database's view.

Hmm. The script would be listening to "_changes", right?

Sorry for the newbie question, but is it possible to store and execute such a custom script in CouchDB so that it can be deployed as easily as views, lists and shows?

Regards,

Aurélien

Re: group_level in reduce function

Posted by Zachary Zolton <za...@gmail.com>.
Folks who really need to chain map-reduced views have to hand-roll
their own solution. This usually involve some scripting to keep a
derived database up-to-date with the output of the source database's
view.


On Wed, Mar 24, 2010 at 2:20 PM, Aurélien Bénel <au...@utt.fr> wrote:
> Thanks for your answer.
>
>> If you want to be able to be able to include the same piece of code in multiple views
> Good idea, I'll do that.
>
>> What do you mean by a script to "combine several views"?
> I mean that the implementations of algorithms that benefit from MapReduce (TF.IDF, Markov chains, K nearest neighbors...) usually need to chain several MapReduces:  the input of a map/reduce is generated by others. I still don't know how to do that in CouchDB.
>
>
> Regards,
>
> Aurélien

Re: group_level in reduce function

Posted by Aurélien Bénel <au...@utt.fr>.
Thanks for your answer.

> If you want to be able to be able to include the same piece of code in multiple views
Good idea, I'll do that.

> What do you mean by a script to "combine several views"?
I mean that the implementations of algorithms that benefit from MapReduce (TF.IDF, Markov chains, K nearest neighbors...) usually need to chain several MapReduces:  the input of a map/reduce is generated by others. I still don't know how to do that in CouchDB.


Regards,

Aurélien

Re: group_level in reduce function

Posted by Zachary Zolton <za...@gmail.com>.
I agree that you'll have an easier time by just creating a second view
with the same map, but a different reduce function.

What do you mean by a script to "combine several views"?

If you want to be able to be able to include the same piece of code in
multiple views, give couchapp a try:

http://github.com/couchapp/couchapp

Cheers,
Zach

On Wed, Mar 24, 2010 at 1:39 PM, Aurélien Bénel <au...@utt.fr> wrote:
> Hmm... Maybe I should write another view for the other level instead.
>
> But is there a way to store a script in CouchDB to combine several views?
> I would not want an external script since I would like to have the script being replicated and synchronized along with the rest of the application...
>
>
> Regards,
>
> Aurélien

Re: group_level in reduce function

Posted by Aurélien Bénel <au...@utt.fr>.
Hmm... Maybe I should write another view for the other level instead.

But is there a way to store a script in CouchDB to combine several views? 
I would not want an external script since I would like to have the script being replicated and synchronized along with the rest of the application...


Regards,

Aurélien