Allow manifest entry to be selected from level 2
This commit is contained in:
parent
3c5740e7bf
commit
90b587b083
1 changed files with 17 additions and 1 deletions
|
@ -256,8 +256,12 @@ merge_lookup(Manifest, LevelIdx, StartKey, EndKey) ->
|
||||||
%% genuinely better - eventually every file has to be compacted.
|
%% genuinely better - eventually every file has to be compacted.
|
||||||
%%
|
%%
|
||||||
%% Hence, the initial implementation is to select files to merge at random
|
%% Hence, the initial implementation is to select files to merge at random
|
||||||
mergefile_selector(Manifest, LevelIdx) ->
|
mergefile_selector(Manifest, LevelIdx) when LevelIdx =< 1 ->
|
||||||
Level = array:get(LevelIdx, Manifest#manifest.levels),
|
Level = array:get(LevelIdx, Manifest#manifest.levels),
|
||||||
|
lists:nth(random:uniform(length(Level)), Level);
|
||||||
|
mergefile_selector(Manifest, LevelIdx) ->
|
||||||
|
Level = leveled_tree:to_list(array:get(LevelIdx,
|
||||||
|
Manifest#manifest.levels)),
|
||||||
lists:nth(random:uniform(length(Level)), Level).
|
lists:nth(random:uniform(length(Level)), Level).
|
||||||
|
|
||||||
add_snapshot(Manifest, Pid, Timeout) ->
|
add_snapshot(Manifest, Pid, Timeout) ->
|
||||||
|
@ -709,6 +713,18 @@ changeup_setup(Man6) ->
|
||||||
|
|
||||||
{Man7, Man8, Man9, Man10, Man11, Man12, Man13}.
|
{Man7, Man8, Man9, Man10, Man11, Man12, Man13}.
|
||||||
|
|
||||||
|
random_select_test() ->
|
||||||
|
ManTuple = initial_setup(),
|
||||||
|
LastManifest = element(7, ManTuple),
|
||||||
|
L1File = mergefile_selector(LastManifest, 1),
|
||||||
|
% This blows up if the function is not prepared for the different format
|
||||||
|
% https://github.com/martinsumner/leveled/issues/43
|
||||||
|
L2File = mergefile_selector(LastManifest, 2),
|
||||||
|
Level1 = array:get(1, LastManifest#manifest.levels),
|
||||||
|
Level2 = leveled_tree:to_list(array:get(2, LastManifest#manifest.levels)),
|
||||||
|
?assertMatch(true, lists:member(L1File, Level1)),
|
||||||
|
?assertMatch(true, lists:member(L2File, Level2)).
|
||||||
|
|
||||||
keylookup_manifest_test() ->
|
keylookup_manifest_test() ->
|
||||||
{Man0, Man1, Man2, Man3, _Man4, _Man5, Man6} = initial_setup(),
|
{Man0, Man1, Man2, Man3, _Man4, _Man5, Man6} = initial_setup(),
|
||||||
LK1_1 = {o, "Bucket1", "K711", null},
|
LK1_1 = {o, "Bucket1", "K711", null},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue