Created
June 1, 2011 03:55
-
-
Save ericmoritz/1001764 to your computer and use it in GitHub Desktop.
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
/* | |
Uses http://jsonselect.org/ to select fields from a riak object | |
*/ | |
function map_jsonselect(values, keydata, arg) { | |
var data = Riak.mapValuesJson(values)[0]; | |
if(typeof arg == "string") { | |
return JSONSelect.match(arg, data); | |
} else if(typeof arg == "object") { | |
var accum = {} | |
for(key in arg) { | |
var result = JSONSelect.match(arg[key], data); | |
if(result.length == 1) { | |
accum[key] = result[0]; | |
} else { | |
accum[key] = result; | |
} | |
} | |
return [accum]; | |
} | |
} |
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": [ ["goog", "2005-05-04"], ["goog", "2005-05-05"]], | |
"query": [ | |
{"map": {"language": "javascript", "name": "map_jsonselect", "arg": {"high": ".High", "low": ".Low"}}}, | |
{"reduce": {"language": "javascript", "source": "function(v) { return v; }"}} | |
]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment