Fix predictable strategy

In the case where a merge results in an output
file that fits in the current level, we will
normally just leave it here; but with if said
level already has a C-file, then we will not
see enough merge steps to actually finish merging
in time.
This commit is contained in:
Kresten Krab Thorup 2012-07-31 15:24:58 +02:00
parent e59c3d7add
commit 166a127a43

View file

@ -546,7 +546,8 @@ main_loop(State = #state{ next=Next }) ->
main_loop(State2#state{ a = AFile, c = undefined, merge_pid=undefined }) main_loop(State2#state{ a = AFile, c = undefined, merge_pid=undefined })
end; end;
?CAST(_From,{merge_done, Count, OutFileName}) when Count =< ?BTREE_SIZE(State#state.level) -> ?CAST(_From,{merge_done, Count, OutFileName})
when Count =< ?BTREE_SIZE(State#state.level), State#state.c =:= undefined ->
?log("merge_done, out:~w~n -> self", [Count]), ?log("merge_done, out:~w~n -> self", [Count]),
@ -666,17 +667,17 @@ do_step(StepFrom, PreviousWork, StepSize, State) ->
%% heuristic doesn't work when there are aggressive deletes (expiry or delete). %% heuristic doesn't work when there are aggressive deletes (expiry or delete).
%% https://github.com/basho/hanoidb/issues/7 %% https://github.com/basho/hanoidb/issues/7
WorkToDoHere = WorkToDoHere =
min(WorkLeftHere, WorkUnitsLeft), %% min(WorkLeftHere, WorkUnitsLeft),
%% case hanoidb:get_opt( merge_strategy, State#state.opts, fast) of case hanoidb:get_opt( merge_strategy, State#state.opts, fast) of
%% fast -> fast ->
%% min(WorkLeftHere, WorkUnitsLeft); min(WorkLeftHere, WorkUnitsLeft);
%% predictable -> predictable ->
%% if (WorkLeftHere < Depth * WorkUnit) -> if (WorkLeftHere < Depth * WorkUnit) ->
%% min(WorkLeftHere, WorkUnit); min(WorkLeftHere, WorkUnit);
%% true -> true ->
%% min(WorkLeftHere, WorkUnitsLeft) min(WorkLeftHere, WorkUnitsLeft)
%% end end
%% end, end,
WorkIncludingHere = PreviousWork + WorkToDoHere, WorkIncludingHere = PreviousWork + WorkToDoHere,
?log("do_step prev:~p, do:~p of ~p ~n", [PreviousWork, WorkToDoHere, WorkLeftHere]), ?log("do_step prev:~p, do:~p of ~p ~n", [PreviousWork, WorkToDoHere, WorkLeftHere]),