Home » Php » php – Reduce Functions in PHPillow for CouchDB

php – Reduce Functions in PHPillow for CouchDB

Posted by: admin July 12, 2020 Leave a comment


I’m trying to do a reduce function (of MapReduce) in PHPillow and currently it’s undocumented, however I really need to do it. Does anyone have an example of implementing a Reduce Function within PHPillow?

http://arbitracker.org/phpillow/download.html <–That’s PHPillow

I’ve had no problems with doing so from Futon or normal map functions, it’s the reduce functions I’m being held up by.

This is in the code

* A reduce function may be used to aggregate / reduce the results
 * calculated by a view function. See the CouchDB documentation for more
 * results: @TODO: Not yet documented.
 * Each view reduce function MUST have a view definition with the same
 * name, otherwise there is nothing to reduce.

Thanks for your help,


How to&Answers:

I will start by saying I don’t know a lot of PHPillow or CouchDB.

But, by the looks of it, a Reduce function is written and registered on the CouchDb server. and it is then referenced in view_file.php – define the array as per their example… lines 35-57.

Then when you call verifyView(), it will perform the reduces defined, which in turn means you can then access it via $views[$name][‘reduce’] perhaps.

As I said, I am just guessing from the little info in the classes and couchdb’s info about reduce.