Skip to content

Commit

Permalink
Allow the ETS backend to continue working with folds
Browse files Browse the repository at this point in the history
  • Loading branch information
rzezeski committed Jun 12, 2012
1 parent bce4abe commit 40ea394
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/riak_search_vnode.erl
Expand Up @@ -173,12 +173,20 @@ handle_command(#range_v1{index = Index,
handle_command(?FOLD_REQ{foldfun=Fun, acc0=Acc},
Sender,
#vstate{bmod=BMod,bstate=BState}=VState) ->
{async, AsyncFoldFun} = BMod:fold(Fun, Acc, BState),
FinishFun =
fun(FinalAcc) ->
riak_core_vnode:reply(Sender, FinalAcc)
end,
{async, {fold, AsyncFoldFun, FinishFun}, Sender, VState}.
%% TODO: Hardcoding async vs. sync logic for now. In future
%% something like KV's backend capabilities should be put in
%% place, or make everything async capable.
case BMod of
merge_index_backend ->
{async, AsyncFoldFun} = BMod:fold(Fun, Acc, BState),
FinishFun =
fun(FinalAcc) ->
riak_core_vnode:reply(Sender, FinalAcc)
end,
{async, {fold, AsyncFoldFun, FinishFun}, Sender, VState};
_ ->
bmod_response(BMod:fold(Fun, Acc, BState), VState)
end.

%% Handle a command during handoff - if it's a fold then
%% make sure it runs locally, otherwise forward it on to the
Expand Down

0 comments on commit 40ea394

Please sign in to comment.