Handle L0 cache being full

A test thta will cause leveled to crash due to a low cache size being set - but protect against this (as well as the general scenario of the cache being full).

There could be a potential case where a L0 file present (post pending) without work backlog being set.  In this case we want to roll the level zero to memory, but don't accept the cache update if the L0 cache is already full.
This commit is contained in:
Martin Sumner 2019-01-14 12:27:51 +00:00
parent d5a9f2e8b7
commit c060c0e41d
4 changed files with 74 additions and 22 deletions

View file

@ -38,7 +38,8 @@
add_to_index/3,
new_index/0,
clear_index/1,
check_index/2
check_index/2,
cache_full/1
]).
-include_lib("eunit/include/eunit.hrl").
@ -52,6 +53,12 @@
%%% API
%%%============================================================================
-spec cache_full(list()) -> boolean().
%% @doc
%% If there are already 127 entries in the cache then the cache is full
cache_full(L0Cache) ->
length(L0Cache) == 127.
-spec prepare_for_index(index_array(), leveled_codec:segment_hash())
-> index_array().
%% @doc