我已经编写了我的reduce阶段,就像HTML页面的分页一样,后端从0获取请求从而计数为10,这样我就必须在reduce阶段显示返回这些值:
reduce_paginate1(L,Arg) ->
[lists:sublist(lists:sort(L),Arg)].
reduce_paginate2(L,[Frm,Cnt]) ->
case Frm > length(L) of
true -> [];
false -> [lists:sublist(L,Frm,Cnt)]
end.
我在我的应用程序中从python-riak客户端调用它:
query.map(['conditions', 'mapfields_check'],
{
'arg': [['user_email', 'eq', 'xxxxxxx@gmail.com'],
['template_name', 'assigned_camps']]
});
query.reduce(['pagiante', 'reduce_paginate1'],
{'arg':frm + count});
query.reduce(['pagiante', 'reduce_paginate2'],
{'arg' : [frm + 1,count],"reduce_phase_only1" : True});
抛出错误:
Error running MapReduce operation.
Headers:
{
'date': 'Tue, 24 Jun 2014 07:56:38 GMT',
'content-length': '1388',
'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,{reduce,1}}},\n
[{
mochijson2,json_encode,2,\n
[{file,"src/mochijson2.erl"},{line,149}]
},\n
{
mochijson2,\'-json_encode_proplist/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_error,2,\n
[
{file,"src/riak_kv_wm_mapred.erl"},\n
{line,70}
]
},\n
{
riak_kv_wm_mapred,pipe_mapred,2,\n
[
{file,"src/riak_kv_wm_mapred.erl"},\n
{line,173}
]
},\n
{
webmachine_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>'
请建议我如何克服这个问题。