Last active
August 4, 2017 16:15
-
-
Save noirbizarre/2ad455bb9e1013268cb47fc7e73bcaff to your computer and use it in GitHub Desktop.
A Map-Reduce listing remaining dataset coverage zones with slashes in identifiers
This file contains 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 characters
/* | |
* List zones with slahes in identifiers with their occurence count | |
*/ | |
function mapZonesWithSlahes() { | |
this.spatial.zones.forEach(function(zone) { | |
if (zone.indexOf('/') >= 0) { | |
emit(zone, 1); | |
} | |
}); | |
} | |
function countOccurences(key, values) { | |
return Array.sum(values); | |
} | |
db.dataset.mapReduce(mapZonesWithSlahes, countOccurences, { | |
// See https://docs.mongodb.com/manual/reference/method/db.collection.mapReduce/#out-options | |
out: 'zones_with_slashes', | |
query: {'spatial.zones': {$exists: true}} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment