Add support for with_lookup head_only

head_only mode cna be run with_lookup - but there is no L0 index created in this case.

So the L0 index wasn't returning a potition list and the L0 cache wasn't being checked.

Code now checks every  position in the L0 cache, when  a lookup is attempted in head_only mode.
This commit is contained in:
Martin Sumner 2018-06-23 15:15:49 +01:00
parent 990e857ebe
commit aedeb0c934
4 changed files with 57 additions and 29 deletions

View file

@ -44,7 +44,7 @@
-include_lib("eunit/include/eunit.hrl").
% -type index_array() :: array:array().
-type index_array() :: any(). % To live with OTP16
-type index_array() :: any()|none. % To live with OTP16
-export_type([index_array/0]).
@ -214,20 +214,20 @@ split_hash({SegmentID, ExtraHash}) ->
check_slotlist(Key, _Hash, CheckList, TreeList) ->
SlotCheckFun =
fun(SlotToCheck, {Found, KV}) ->
case Found of
true ->
fun(SlotToCheck, {Found, KV}) ->
case Found of
true ->
{Found, KV};
false ->
CheckTree = lists:nth(SlotToCheck, TreeList),
case leveled_tree:match(Key, CheckTree) of
none ->
{Found, KV};
false ->
CheckTree = lists:nth(SlotToCheck, TreeList),
case leveled_tree:match(Key, CheckTree) of
none ->
{Found, KV};
{value, Value} ->
{true, {Key, Value}}
end
{value, Value} ->
{true, {Key, Value}}
end
end,
end
end,
lists:foldl(SlotCheckFun,
{false, not_found},
lists:reverse(CheckList)).