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,18 +672,23 @@ 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
{LastKey, _LastVal} = lists:last(L0), [] ->
case LastKey of {[], false, false};
EndKey -> L0 ->
{L0, true, false}; {LastKey, _LastVal} = lists:last(L0),
_ -> case LastKey of
LTail = leveled_skiplist:key_above_notequals(SkipList, LastKey), EndKey ->
case LTail of
false ->
{L0, true, false}; {L0, true, false};
_ -> _ ->
{L0 ++ [LTail], true, true} LTail = leveled_skiplist:key_above_notequals(SkipList,
LastKey),
case LTail of
false ->
{L0, true, false};
_ ->
{L0 ++ [LTail], true, true}
end
end end
end. end.