Address review comments
More efficient traversal of list to score.
This commit is contained in:
parent
28c88ef8b8
commit
9838e255d2
2 changed files with 17 additions and 11 deletions
|
@ -188,7 +188,7 @@ merge(SrcLevel, Manifest, RootPath, OptsSST) ->
|
||||||
end,
|
end,
|
||||||
SelectMethod =
|
SelectMethod =
|
||||||
case leveled_rand:uniform(100) of
|
case leveled_rand:uniform(100) of
|
||||||
R when R < ?GROOMING_PERC ->
|
R when R =< ?GROOMING_PERC ->
|
||||||
{grooming, fun grooming_scorer/1};
|
{grooming, fun grooming_scorer/1};
|
||||||
_ ->
|
_ ->
|
||||||
random
|
random
|
||||||
|
@ -297,18 +297,23 @@ do_merge(KL1, KL2, SinkLevel, SinkB, RP, NewSQN, MaxSQN, OptsSST, Additions) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec grooming_scorer(list(manifest_entry())) -> manifest_entry().
|
-spec grooming_scorer(list(manifest_entry())) -> manifest_entry().
|
||||||
grooming_scorer(Sample) ->
|
grooming_scorer([ME | MEs]) ->
|
||||||
ScoringFun =
|
InitTombCount = leveled_sst:sst_gettombcount(ME#manifest_entry.owner),
|
||||||
fun(ME) ->
|
{HighestTC, BestME} = grooming_scorer(InitTombCount, ME, MEs),
|
||||||
TombCount = leveled_sst:sst_gettombcount(ME#manifest_entry.owner),
|
|
||||||
{TombCount, ME}
|
|
||||||
end,
|
|
||||||
ScoredSample =
|
|
||||||
lists:reverse(lists:ukeysort(1, lists:map(ScoringFun, Sample))),
|
|
||||||
[{HighestTC, BestME}|_Rest] = ScoredSample,
|
|
||||||
leveled_log:log("PC024", [HighestTC]),
|
leveled_log:log("PC024", [HighestTC]),
|
||||||
BestME.
|
BestME.
|
||||||
|
|
||||||
|
grooming_scorer(HighestTC, BestME, []) ->
|
||||||
|
{HighestTC, BestME};
|
||||||
|
grooming_scorer(HighestTC, BestME, [ME | MEs]) ->
|
||||||
|
TombCount = leveled_sst:sst_gettombcount(ME#manifest_entry.owner),
|
||||||
|
case TombCount > HighestTC of
|
||||||
|
true ->
|
||||||
|
grooming_scorer(TombCount, ME, MEs);
|
||||||
|
false ->
|
||||||
|
grooming_scorer(HighestTC, BestME, MEs)
|
||||||
|
end.
|
||||||
|
|
||||||
return_deletions(ManifestSQN, PendingDeletionD) ->
|
return_deletions(ManifestSQN, PendingDeletionD) ->
|
||||||
% The returning of deletions had been seperated out as a failure to fetch
|
% The returning of deletions had been seperated out as a failure to fetch
|
||||||
% here had caased crashes of the clerk. The root cause of the failure to
|
% here had caased crashes of the clerk. The root cause of the failure to
|
||||||
|
|
|
@ -464,7 +464,8 @@ mergefile_selector(Manifest, LevelIdx, {grooming, ScoringFun}) ->
|
||||||
Sample =
|
Sample =
|
||||||
lists:usort(lists:foldl(SelectorFun, [], lists:seq(1, ?GROOM_SAMPLE))),
|
lists:usort(lists:foldl(SelectorFun, [], lists:seq(1, ?GROOM_SAMPLE))),
|
||||||
% Note that Entries may be less than GROOM_SAMPLE, if same one picked
|
% Note that Entries may be less than GROOM_SAMPLE, if same one picked
|
||||||
% multiple times
|
% multiple times. Level cannot be empty, as otherwise a merge would not
|
||||||
|
% have been chosen at this level
|
||||||
ScoringFun(Sample).
|
ScoringFun(Sample).
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue