Created
June 6, 2012 17:53
-
-
Save dermoth/2883573 to your computer and use it in GitHub Desktop.
mapred test
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
{ | |
"inputs":{ | |
"bucket":"webaccesslogs", | |
"index":"ts_int", | |
"start":1338712811, | |
"end":1338712814, | |
"timeout":60000 | |
}, | |
"query":[ | |
{ | |
"map":{"language":"javascript","source":" | |
function(value, keyData, arg) { | |
var data = Riak.mapValuesJson(value)[0]; | |
r = {}; | |
if(data.remote_addr) | |
r[data.remote_addr] = 1; | |
return [r]; | |
} | |
"}},{"reduce":{ | |
"language":"javascript","source":" | |
function(values, arg){ | |
return values.reduce(function(acc, item){ | |
for (ip in item) { | |
if(acc[ip]) { | |
acc[ip] += item[ip]; | |
} else { | |
acc[ip] = item[ip]; | |
} | |
} | |
return acc; | |
}); | |
} | |
"} | |
} | |
] | |
} |
Author
dermoth
commented
Jun 7, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment