I need to write a a reduce_slice function in erlang that I'll load into riak, I'm doing this so I don't need to use the javascript one which has already once maxed out the js_thread_stack memory.
This is my function so far: reduce_slice(WList,{Page,PageSize}) -> lager:info("Page and PageSize ~p - ~p",[Page,PageSize]), lists:sublist(WList, Page, PageSize). This "works". The problem is that because the reduce phase gets executed with whatever it has at any given moment, the end result is always different. So I need to call this phase with reduce_phase_only_1 as a param, and here is where I'm a bit lost, this is how I call the function now: {reduce,{modfun,whisper_db,reduce_slice},{Page,PageSize},true}]) I see that in the Riak's MapReduce documentation you can call a function with "reduce_phase_only_1" like so: {reduce, FunSpec, [reduce_phase_only_1], Keep} So I tried: {reduce,{modfun,whisper_db,reduce_slice},[reduce_phase_only_1, {Page,PageSize}],true}]) Which throws (of course because of the the function definition is not expecting a list): Supervisor riak_pipe_vnode_worker_sup had child undefined started with {riak_pipe_vnode_worker,start_link,undefined} at <0.2927.0> exit with reason no function clause matching whisper_db:reduce_slice([ I also tried: {reduce,{modfun,whisper_db,reduce_slice},{reduce_phase_only_1,{Page,PageSize}},true}]), and changing the function definition to: reduce_slice(WList,{Phase,{Page,PageSize}}) -> lager:info("Page and PageSize ~p - ~p",[Page,PageSize]), lists:sublist(WList, Page, PageSize). I get the same problem as my first example (different results every time). So I'm not sure the reduce function definition is wrong, or I'm invoking it wrong. Thanks in advance for any help. Manuel
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com