Skip to content

Instantly share code, notes, and snippets.

@seth
Created September 5, 2010 05:33
Show Gist options
  • Select an option

  • Save seth/565778 to your computer and use it in GitHub Desktop.

Select an option

Save seth/565778 to your computer and use it in GitHub Desktop.
session for erlang fun in riak REST map reduce
[orange] riak/dev: cat map-ex.json
{"inputs":[["goog","2010-01-04"],
["goog","2010-01-05"],
["goog","2010-01-06"],
["goog","2010-01-07"],
["goog","2010-01-08"]],
"query":[{"map":{"language":"erlang",
"source":"fun(G, _, _) ->
O = [riak_object:get_value(G)],
{struct, D} = mochijson2:decode(O),
[proplists:get_value(<<\"High\">>, D)]
end.",
"keep":true
}},
{"reduce":{"language":"erlang",
"source":"
fun(ValueList, _Arg) ->
[lists:foldl(fun erlang:'+'/2, 0, ValueList)]
end.
", "keep":true}}]
}
[orange] riak/dev: curl -is -H"content-type: application/json" \
http://localhost:8093/mapred -d@map-ex.json
HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.7.1 (participate in the frantic)
Date: Sun, 05 Sep 2010 05:32:49 GMT
Content-Type: application/json
Content-Length: 47
[[603.25,610.0,625.86,627.84,629.51],[3096.46]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment