Skip to content

Instantly share code, notes, and snippets.

@9b
Created March 24, 2011 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 9b/885702 to your computer and use it in GitHub Desktop.
Save 9b/885702 to your computer and use it in GitHub Desktop.
Unique encoded named functions with instance and total counts
var map = function () {
this.structure.keywords.keyword.forEach(function (z) {emit(z.name, {count_hex: z.hexcodecount, count:1});});
}
var reduce = function (key, values) {
var total = 0;
var count = 0;
for (var i = 0; i < values.length; i++) {
if (values[i].count_hex > 0) {
total += values[i].count_hex;
count++;
}
}
avg = total/count;
return { count_hex:total, count: count};
}
db.malware.mapReduce(map,reduce, {out: "named_funcs_hex" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment