Skip to content

Instantly share code, notes, and snippets.

@aphyr
Created December 7, 2010 21:53
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 aphyr/732494 to your computer and use it in GitHub Desktop.
Save aphyr/732494 to your computer and use it in GitHub Desktop.
POST /mapred HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: 795
X-Riak-Clientid: Lr5XMw==
Host: 192.168.1.116:8098
{"inputs":[["tablet_feeds","kyletest2"]],"query":[{"map":{"arg":{"limit":32,"offset":0},"language":"javascript","keep":false,"source":"\n function(v, keydata, opts) {\n o = JSON.parse(v.values[0].data);\n items = o.items.slice(opts.offset, opts.offset + opts.limit);\n return items.map(function(item) {\n return ['tablet_feed_items', item]\n });\n }\n "}},{"map":{"language":"javascript","keep":false,"source":"\n function(v) {\n o = JSON.parse(v.values[0].data);\n o.key = v.key;\n return [o];\n }\n "}},{"reduce":{"language":"javascript","keep":true,"source":"\n function(items) {\n return items.sort(function(a, b) {\n return(a.created_at < b.created_at);\n })\n }\n "}}]}HTTP/1.1 500 Internal Server Error
Server: MochiWeb/1.1 WebMachine/1.7.2 (participate in the frantic)
Date: Tue, 07 Dec 2010 21:47:44 GMT
Content-Type: application/json
Content-Length: 86
{"lineno":16,"message":"TypeError: final_user.source is undefined","source":"unknown"}
## Source
function(v, keydata, opts) {
o = JSON.parse(v.values[0].data);
items = o.items.slice(opts.offset, opts.offset + opts.limit);
return items.map(function(item) {
return ['tablet_feed_items', item]
});
}
}, :arg => page_opts).map(%{
function(v) {
o = JSON.parse(v.values[0].data);
o.key = v.key;
return [o];
}
}).reduce(%{
function(items) {
return items.sort(function(a, b) {
return(a.created_at < b.created_at);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment