Add some crash protection for empty return from to_range

Not clear though why it would occur.
This commit is contained in:
martinsumner 2016-12-29 03:04:10 +00:00
parent 3f3b36597a
commit 5b9e68df99

View file

@ -672,19 +672,24 @@ lookup_slots_int(StartKey, all, SkipList) ->
LTrim = FirstKey < StartKey, LTrim = FirstKey < StartKey,
{RKeep0, LTrim, false}; {RKeep0, LTrim, false};
lookup_slots_int(StartKey, EndKey, SkipList) -> lookup_slots_int(StartKey, EndKey, SkipList) ->
L0 = leveled_skiplist:to_range(SkipList, StartKey, EndKey), case leveled_skiplist:to_range(SkipList, StartKey, EndKey) of
[] ->
{[], false, false};
L0 ->
{LastKey, _LastVal} = lists:last(L0), {LastKey, _LastVal} = lists:last(L0),
case LastKey of case LastKey of
EndKey -> EndKey ->
{L0, true, false}; {L0, true, false};
_ -> _ ->
LTail = leveled_skiplist:key_above_notequals(SkipList, LastKey), LTail = leveled_skiplist:key_above_notequals(SkipList,
LastKey),
case LTail of case LTail of
false -> false ->
{L0, true, false}; {L0, true, false};
_ -> _ ->
{L0 ++ [LTail], true, true} {L0 ++ [LTail], true, true}
end end
end
end. end.