On Mon, Dec 14, 2009 at 6:32 PM, Andreas Pavlogiannis
<[email protected]> wrote:
> Hello,
>
> I have created a filesystem so that each document is either a file or a
> folder (having the respective attribute), and has it's path stored in a
> list. For example document /root/home/photos/party has a path attribute:
> ['root', 'home', 'photos']. I would like to have a reduce function in order
> to calculate the total size of each file and folder, and each time get the
> result using the key value in queues.
>
> Is it possible? And if so, could you provide me some pointers please?
>
> Thanks,
>
> Andreas
>
//map function:
function(doc) {
if(doc.is_file) emit(doc.path_as_array, doc.file_size);
}
//reduce function:
function(keys, values, rereduce) {
return sum(values);
}
# Query:
$ curl
'http://127.0.0.1:5984/db_name/_design/filesystem/_view/file_sizes?key=["root","home","photos"]'
HTH,
Paul Davis