0

How can send the parameters to the:

query.map()

function as given in the "http://basho.github.io/riak-python-client/query.html#riak.mapreduce.RiakMapReduce.map".

I am having map.erl in erlmap fodler in mysystem. In that i am having Map function.

I have given like this:

>>> query.map(['/home/intel/gopi/sam_programmes/erl/erlmap/map.erl','Map'],options={'language':'erlang'})

After going for command:

query.run()

It is throwing error:

Traceback (most recent call last):

File "<input>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/riak-1.5.2-py2.6.egg/riak/mapreduce.py", line 234, in run
result = t.mapred(self._inputs, query, timeout)
File "/usr/lib/python2.6/site-packages/riak-1.5.2-py2.6.egg/riak/transports/http.py", line 322, in mapred
(repr(response[0]), repr(response[1])))
Exception: Error running MapReduce operation. Headers: {'date': 'Wed, 21 May 2014 07:27:23 GMT', 'content-length': '1391', 'content-type': 'text/html', 'http
_code': 500, 'server': 'MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)'} Body: '<html><head><title>500 Internal Server Error</title></head><body><
h1>Internal Server Error</h1>The server encountered an error while processing this request:<br><pre>{error,{exit,{json_encode,{bad_term,{xform_map,0}}},\n
      [{mochijson2,json_encode,2,\n                          [{file,"src/mochijson2.erl"},{line,149}]},\n              {mochijson2,\'-json_encode_proplis
t/2-fun-0-\',3,\n                          [{file,"src/mochijson2.erl"},{line,167}]},\n              {lists,foldl,3,[{file,"lists.erl"},{line,1197}]},\n
     {mochijson2,json_encode_proplist,2,\n                          [{file,"src/mochijson2.erl"},{line,170}]},\n              {riak_kv_wm_mapred,send_err
or,2,\n                                 [{file,"src/riak_kv_wm_mapred.erl"},\n                                  {line,70}]},\n              {riak_kv_wm_mapre
d,pipe_mapred,2,\n                                 [{file,"src/riak_kv_wm_mapred.erl"},\n                                  {line,173}]},\n      {webm
achine_resource,resource_call,3,\n                                   [{file,"src/webmachine_resource.erl"},\n                                    {line,186}]}
,\n              {webmachine_resource,do,3,\n                                   [{file,"src/webmachine_resource.erl"},\n                                    {
line,142}]}]}}</pre><P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></body></html>'
Krish gopi
  • 155
  • 4
  • 12

1 Answers1

0

The map function will be executed by the individual vnodes on the various Riak nodes. What you send in the .map() should be the lowercase names (atoms) of a module and function that is already compiled and either loaded or available in the code path for each node. The vnodes processing the map phase will not have access to an uncompiled source file on your local machine.

When you are using the Erlang client, you can define the map function as an anonymous fun, and pass the function object in the mapred call, but the python client is unable to compile the fun into bytecode the vnodes can run.

Joe
  • 25,000
  • 3
  • 22
  • 44
  • how to use mochijson in erlang shell. >mochijson:encode(L) then i am getting error like ** exception error: undefined function mochijson2:encode/1 in the erlang shell – Krish gopi May 23 '14 at 07:56
  • can you please elaborate the steps to get the above thing work – Krish gopi May 23 '14 at 13:16
  • now i have kept the beam files and also mentioned in the app.config but still getting the error, i am passing like query.map(['maps,'funs']) and then going for query.run() but no use getting the error. – Krish gopi May 23 '14 at 13:19
  • i am getting this in my error.log 2014-05-23 18:20:11.167 [error] <0.6769.4> CRASH REPORT Process <0.6769.4> with 0 neighbours exited with reason: processing_error in gen_fsm:terminate/7 line 611 2014-05-23 18:20:11.167 [error] <0.998.0> Supervisor {<0.998.0>,riak_pipe_vnode_worker_sup} had child undefined started with {riak_pipe_vnode_worker,start_link,undefined} at <0.6769.4> exit with reason processing_error in context child_terminated – Krish gopi May 23 '14 at 13:26
  • I've started a chat where we can discuss with more space: http://chat.stackoverflow.com/rooms/54306/discussion-related-to-http-stackoverflow-com-questions-23776792-how-to-send-par – Joe May 23 '14 at 20:11