如何将参数发送到地图减少了python-riak客户端使用erlang在riak中的查询

时间:2014-05-21 07:31:09

标签: python erlang python-2.6 riak erlang-shell

如何将参数发送到:

query.map()

" http://basho.github.io/riak-python-client/query.html#riak.mapreduce.RiakMapReduce.map"。

中给出的功能

我在mysystem中的erlmap fodler中有map.erl。因为我有Map功能。

我这样给了:

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

寻求命令后:

query.run()

抛出错误:

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>'

1 个答案:

答案 0 :(得分:0)

map函数将由各种Riak节点上的各个vnode执行。您在.map()中发送的内容应该是已编译并在每个节点的代码路径中加载或可用的模块和函数的小写名称(原子)。处理映射阶段的vnode将无法访问本地计算机上的未编译源文件。

当您使用Erlang客户端时,您可以将map函数定义为匿名函数,并在mapred调用中传递函数对象,但是python客户端无法将函数编译为字节码vnodes可以跑。