Correct botched manifest entry removal

This commit is contained in:
martinsumner 2017-01-17 10:53:13 +00:00
parent 5076187545
commit 14ebf94e56
2 changed files with 8 additions and 8 deletions

View file

@ -154,7 +154,7 @@
{"PC011",
{info, "Merge completed with MSN=~w to Level=~w and FileCounter=~w"}},
{"PC012",
{debug, "File to be created as part of MSN=~w Filename=~s "
{info, "File to be created as part of MSN=~w Filename=~s "
++ "IsBasement=~w"}},
{"PC013",
{warn, "Merge resulted in empty file ~s"}},
@ -167,7 +167,7 @@
{"PC018",
{info, "Saved manifest file"}},
{"PC019",
{info, "After ~s level ~w is ~w"}},
{debug, "After ~s level ~w is ~w"}},
{"I0001",
{info, "Unexpected failure to fetch value for Key=~w SQN=~w "

View file

@ -332,18 +332,18 @@ add_entry(_LevelIdx, Level, Entry) ->
remove_entry(_LevelIdx, Level, Entries) when is_list(Entries) ->
% We're assuming we're removing a sorted sublist
RemLength = length(Entries),
RemStart = lists:nth(1, Entries),
remove_section(Level, RemStart#manifest_entry.start_key, RemLength - 1);
[RemStart|_Tail] = Entries,
remove_section(Level, RemStart#manifest_entry.start_key, RemLength);
remove_entry(_LevelIdx, Level, Entry) ->
remove_section(Level, Entry#manifest_entry.start_key, 0).
remove_section(Level, Entry#manifest_entry.start_key, 1).
remove_section(Level, StartKey, Length) ->
remove_section(Level, SectionStartKey, SectionLength) ->
PredFun =
fun(E) ->
E#manifest_entry.start_key < StartKey
E#manifest_entry.start_key < SectionStartKey
end,
{Pre, Rest} = lists:splitwith(PredFun, Level),
Post = lists:nthtail(length(Rest) - Length, Rest),
Post = lists:nthtail(SectionLength, Rest),
Pre ++ Post.