Fixed issues
Two issues - when the key range falls in-between two marks in the summary, we didn't pick up any mark. then when trimming both right and left, the left trim was being discarded.
This commit is contained in:
parent
5b9e68df99
commit
55386622f7
2 changed files with 37 additions and 2 deletions
|
@ -673,6 +673,32 @@ skiplist_keybefore_test() ->
|
||||||
io:format(user, "~nFinding self in keys above ~w microseconds for ~w finds~n",
|
io:format(user, "~nFinding self in keys above ~w microseconds for ~w finds~n",
|
||||||
[timer:now_diff(os:timestamp(), SW), N]).
|
[timer:now_diff(os:timestamp(), SW), N]).
|
||||||
|
|
||||||
|
skiplist_range_test() ->
|
||||||
|
N = 150,
|
||||||
|
KL = generate_randomkeys(1, N, 1, N div 5),
|
||||||
|
|
||||||
|
KLSL1 = lists:sublist(lists:ukeysort(1, KL), 128),
|
||||||
|
SkipList1 = from_list(KLSL1),
|
||||||
|
{LastK1, V1} = lists:last(KLSL1),
|
||||||
|
R1 = to_range(SkipList1, LastK1, LastK1),
|
||||||
|
?assertMatch([{LastK1, V1}], R1),
|
||||||
|
|
||||||
|
KLSL2 = lists:sublist(lists:ukeysort(1, KL), 127),
|
||||||
|
SkipList2 = from_list(KLSL2),
|
||||||
|
{LastK2, V2} = lists:last(KLSL2),
|
||||||
|
R2 = to_range(SkipList2, LastK2, LastK2),
|
||||||
|
?assertMatch([{LastK2, V2}], R2),
|
||||||
|
|
||||||
|
KLSL3 = lists:sublist(lists:ukeysort(1, KL), 129),
|
||||||
|
SkipList3 = from_list(KLSL3),
|
||||||
|
{LastK3, V3} = lists:last(KLSL3),
|
||||||
|
R3 = to_range(SkipList3, LastK3, LastK3),
|
||||||
|
?assertMatch([{LastK3, V3}], R3),
|
||||||
|
|
||||||
|
{FirstK4, V4} = lists:nth(1, KLSL3),
|
||||||
|
R4 = to_range(SkipList3, FirstK4, FirstK4),
|
||||||
|
?assertMatch([{FirstK4, V4}], R4).
|
||||||
|
|
||||||
|
|
||||||
empty_skiplist_size_test() ->
|
empty_skiplist_size_test() ->
|
||||||
?assertMatch(0, leveled_skiplist:size(empty(false))),
|
?assertMatch(0, leveled_skiplist:size(empty(false))),
|
||||||
|
|
|
@ -674,7 +674,8 @@ lookup_slots_int(StartKey, all, SkipList) ->
|
||||||
lookup_slots_int(StartKey, EndKey, SkipList) ->
|
lookup_slots_int(StartKey, EndKey, SkipList) ->
|
||||||
case leveled_skiplist:to_range(SkipList, StartKey, EndKey) of
|
case leveled_skiplist:to_range(SkipList, StartKey, EndKey) of
|
||||||
[] ->
|
[] ->
|
||||||
{[], false, false};
|
BestKey = leveled_skiplist:key_above(SkipList, StartKey),
|
||||||
|
{[BestKey], true, true};
|
||||||
L0 ->
|
L0 ->
|
||||||
{LastKey, _LastVal} = lists:last(L0),
|
{LastKey, _LastVal} = lists:last(L0),
|
||||||
case LastKey of
|
case LastKey of
|
||||||
|
@ -788,7 +789,7 @@ trim_slot(SlotBinary, StartKey, EndKey) ->
|
||||||
all ->
|
all ->
|
||||||
LTrimL;
|
LTrimL;
|
||||||
_ ->
|
_ ->
|
||||||
{LKeep, _RDrop} = lists:splitwith(RTrimFun, L),
|
{LKeep, _RDrop} = lists:splitwith(RTrimFun, LTrimL),
|
||||||
LKeep
|
LKeep
|
||||||
end,
|
end,
|
||||||
RTrimL.
|
RTrimL.
|
||||||
|
@ -1176,6 +1177,14 @@ simple_persisted_test() ->
|
||||||
?assertMatch(SubKVListA3L, length(FetchedListB3)),
|
?assertMatch(SubKVListA3L, length(FetchedListB3)),
|
||||||
?assertMatch(SubKVListA3, FetchedListB3),
|
?assertMatch(SubKVListA3, FetchedListB3),
|
||||||
|
|
||||||
|
io:format("Eight hundredth key ~w~n", [Eight000Key]),
|
||||||
|
FetchListB4 = sst_getkvrange(Pid,
|
||||||
|
Eight000Key,
|
||||||
|
Eight000Key,
|
||||||
|
4),
|
||||||
|
FetchedListB4 = lists:foldl(FoldFun, [], FetchListB4),
|
||||||
|
?assertMatch([{Eight000Key, _v800}], FetchedListB4),
|
||||||
|
|
||||||
ok = sst_close(Pid),
|
ok = sst_close(Pid),
|
||||||
ok = file:delete(Filename ++ ".sst").
|
ok = file:delete(Filename ++ ".sst").
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue