Last active
December 20, 2015 13:39
Revisions
-
sebastianvoss renamed this gist
Aug 2, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sebastianvoss created this gist
Aug 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ // map function m = function () { this.images.forEach( function(id) { emit(id, 1); }) } // reduce function r = function (id, count) { return Array.sum(count); } // create a image count in collection map_reduce_sample db.albums.mapReduce(m, r, {out: "map_reduce_sample"}) // tag all images which are in use db.map_reduce_sample.find().forEach(function(d) { db.images.update({_id: d._id}, {$set: {in_use: true}}) }) // remove unused images db.images.remove({in_use: {$exists: false}}) // remove in_use tag db.images.update({}, {$unset: {in_use: ""}})