Removed daft last function from SFT
This commit is contained in:
parent
0905ea51e2
commit
0cf96e7198
1 changed files with 13 additions and 18 deletions
|
@ -722,13 +722,8 @@ fetch_block(Handle, LengthList, BlockNmb, StartOfSlot) ->
|
||||||
binary_to_term(BlockToCheckBin).
|
binary_to_term(BlockToCheckBin).
|
||||||
|
|
||||||
%% Need to deal with either Key or {next, Key}
|
%% Need to deal with either Key or {next, Key}
|
||||||
get_nearestkey(KVList, all) ->
|
get_nearestkey([H|_Tail], all) ->
|
||||||
case KVList of
|
H;
|
||||||
[] ->
|
|
||||||
not_found;
|
|
||||||
[H|_Tail] ->
|
|
||||||
H
|
|
||||||
end;
|
|
||||||
get_nearestkey(KVList, Key) ->
|
get_nearestkey(KVList, Key) ->
|
||||||
case Key of
|
case Key of
|
||||||
{next, K} ->
|
{next, K} ->
|
||||||
|
@ -1031,16 +1026,16 @@ create_slot(KL1, KL2, LevelR, BlockCount, SegLists, SerialisedSlot, LengthList,
|
||||||
{null, LSN, HSN, LastKey, Status};
|
{null, LSN, HSN, LastKey, Status};
|
||||||
{null, _} ->
|
{null, _} ->
|
||||||
[NewLowKeyV|_] = BlockKeyList,
|
[NewLowKeyV|_] = BlockKeyList,
|
||||||
|
NewLastKey = lists:last([{keyonly, LastKey}|BlockKeyList]),
|
||||||
{leveled_codec:strip_to_keyonly(NewLowKeyV),
|
{leveled_codec:strip_to_keyonly(NewLowKeyV),
|
||||||
min(LSN, LSNb), max(HSN, HSNb),
|
min(LSN, LSNb), max(HSN, HSNb),
|
||||||
leveled_codec:strip_to_keyonly(last(BlockKeyList,
|
leveled_codec:strip_to_keyonly(NewLastKey),
|
||||||
{last, LastKey})),
|
|
||||||
Status};
|
Status};
|
||||||
{_, _} ->
|
{_, _} ->
|
||||||
|
NewLastKey = lists:last([{keyonly, LastKey}|BlockKeyList]),
|
||||||
{LowKey,
|
{LowKey,
|
||||||
min(LSN, LSNb), max(HSN, HSNb),
|
min(LSN, LSNb), max(HSN, HSNb),
|
||||||
leveled_codec:strip_to_keyonly(last(BlockKeyList,
|
leveled_codec:strip_to_keyonly(NewLastKey),
|
||||||
{last, LastKey})),
|
|
||||||
Status}
|
Status}
|
||||||
end,
|
end,
|
||||||
SerialisedBlock = serialise_block(BlockKeyList),
|
SerialisedBlock = serialise_block(BlockKeyList),
|
||||||
|
@ -1050,13 +1045,6 @@ create_slot(KL1, KL2, LevelR, BlockCount, SegLists, SerialisedSlot, LengthList,
|
||||||
SerialisedSlot2, LengthList ++ [BlockLength],
|
SerialisedSlot2, LengthList ++ [BlockLength],
|
||||||
TrackingMetadata).
|
TrackingMetadata).
|
||||||
|
|
||||||
|
|
||||||
last([], {last, LastKey}) -> {keyonly, LastKey};
|
|
||||||
last([E|Es], PrevLast) -> last(E, Es, PrevLast).
|
|
||||||
|
|
||||||
last(_, [E|Es], PrevLast) -> last(E, Es, PrevLast);
|
|
||||||
last(E, [], _) -> E.
|
|
||||||
|
|
||||||
serialise_block(BlockKeyList) ->
|
serialise_block(BlockKeyList) ->
|
||||||
term_to_binary(BlockKeyList, [{compressed, ?COMPRESSION_LEVEL}]).
|
term_to_binary(BlockKeyList, [{compressed, ?COMPRESSION_LEVEL}]).
|
||||||
|
|
||||||
|
@ -2023,6 +2011,13 @@ filename_test() ->
|
||||||
"../tmp/subdir/file_name.sft"},
|
"../tmp/subdir/file_name.sft"},
|
||||||
generate_filenames(FN3)).
|
generate_filenames(FN3)).
|
||||||
|
|
||||||
|
empty_file_test() ->
|
||||||
|
{ok, Pid, _Reply} = sft_new("../test/emptyfile.pnd", [], [], 1),
|
||||||
|
?assertMatch(not_present, sft_get(Pid, "Key1")),
|
||||||
|
?assertMatch([], sft_getkvrange(Pid, all, all, 16)),
|
||||||
|
ok = sft_clear(Pid).
|
||||||
|
|
||||||
|
|
||||||
nonsense_coverage_test() ->
|
nonsense_coverage_test() ->
|
||||||
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
|
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
|
||||||
undefined = gen_fsm:sync_send_all_state_event(Pid, nonsense),
|
undefined = gen_fsm:sync_send_all_state_event(Pid, nonsense),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue