erlang - Mapreduce with Riak -


Does anyone have example code for cartridge for Riak which can be run on a riege node.

  cd ~ / riak erl -name zed@127.0.0.1 -setup riak -pa apps / Riak / ebin  

In Open:

  Connect to Server & gt; {OK, Client} = Repeat: Client_connect ('RIK @ 127.0.0.1'). {OK, {riak_client, 'riak @ 127.0.0.1', & lt; 6,201,208,64 & gt; & Gt;}} Create and insert merchandise & gt; Customer: put (riak_object: new (<< groceries} >>  
  • << <, < ]), 1). OK & gt; Client: put (riak_object: new (>
  • "yours"> gt; & gt; [["egg", "sausage" ]), 1). OK # Make maps and reduce the functions & gt; Calculation = Fun (live, 'undefined', 'none') - & gt; [DC: from_list ([[I, 1]) I & lt; - riak_object: get_value (g)])] end # Fun & LT; Erl_eval.18.105910772 & gt; & Gt; Merge = Fun (Gcounts, 'none') - & gt; [Lists: GUN (funny (G, ACC) -> Dict: Merge (funny (_, x, y) -> x + y and, g, acc) end, dictionary: new (), jicount)] end . # Fun & LT; Erl_eval.12.113037538 & gt; # Reduce the map & gt; {OK, [R]} = Client: Mapad ([[& lt; <"Grocery stuff"> << <, dict: to_list (r). [{"Eggs", 2}, {"shasija", 1}, {"bacon", 1}]
  • < P> I have used default config for the server:

      $ hg clone http://hg.basho.com/riak/ $ cd riak $ ./rebar compile $ Cd rel $ ./riak/bin/riak start  

    Comments

    Popular posts from this blog

    oracle - The fastest way to check if some records in a database table? -

    php - multilevel menu with multilevel array -

    jQuery UI: Datepicker month format -