我想在erlang中执行mapreduce查询,该查询包含两个映射阶段,以便Map2函数将Map1函数的结果作为输入.是否可能以及每个地图阶段的返回值是什么
我使用两个简单的map函数运行了一个测试mapred查询,每个函数都返回一个输入对象(在列表中).但是通过runnin查询我得到一个badmatch错误
Map1 = fun(O,_,_) -> [O] end.
Map2 = fun(O, _,_) -> [O] end.
C:mapred_bucket(<<"b7bc1418-198d-44a3-8835-8aa9cb416d5b">>, [{map, {qfun, Map1}, none, false}, {map, {qfun, Map2}, none, true}]).
{{badmatch,{r_object,<<"b7bc1418-198d-44a3-8835-8aa9cb416d5b">>,
<<255,230,193,167,254,7,246,64,154,190,36,236,32,232,189,
169,161,124,23,86>>,
[{r_content,{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],...}}},
<<"12d33872-4c92-4da5-9d16-5036a8059253">>}],
[{<<5,215,86,61>>,{1,63487018636}}],
{dict,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
undefined}},
[{riak_kv_map_phase,build_input,2},
{riak_kv_map_phase,'-handle_input/3-lc$^0/1-0-',2},
{riak_kv_map_phase,handle_input,3},
{luke_phase,executing,2},
{gen_fsm,handle_msg,7},
{proc_lib,init_p_do_apply,3}]}
Run Code Online (Sandbox Code Playgroud)
我正在使用riak_search-0.14.2
Erlang R14B03(erts-5.8.4)
谢谢!
我不确定在Erlang中Map方法的签名是什么,因为我在Javascript中只做了map/reduce,但我会尽力帮助.
为了链接地图阶段,只有最后一个地图函数需要返回Riak中的对象列表.它上面的每个其他map函数都需要返回一个包含存储桶名称和传入值的键的元组.
在Javascript中,我完成了这样的事情:
function map_function(value, keydata, arg) {
//filtering stuff here
if(arg.last) {
data["key"] = value.key;
return [data];
}
else {
return [[value.bucket, value.key]];
}
//this is in the case the filter returns true; if the filter returns false, return an empty tuple
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
748 次 |
| 最近记录: |