anchor.diff:  %%      ""wrapping around", i.e. its begin is larger than its end.
   %%      Returns the chunk and the remaining interval for which the DB may still
   %%      have data (a subset of I).
  -%%      Precond: Interval is a subset of the range of the dht_node and thus, in
  -%%      particular, continuous
  --spec get_chunk(DB::db(), Interval::intervals:interval(), ChunkSize::pos_integer()) ->
  -    {intervals:interval(), db_as_list()}.
  -get_chunk(DB, Interval, ChunkSize) -> get_chunk_(DB, Interval, ChunkSize).
  -
  --spec get_chunk_(DB::db_t(), Interval::intervals:interval(), ChunkSize::pos_integer()) ->
  -    {intervals:interval(), db_as_list()}.
  -get_chunk_({ETSDB, _Subscr} = DB, Interval, ChunkSize) ->
  +%%      Precond: Interval is a subset of the range of the dht_node and continuous!
  +-spec get_chunk(DB::db(), Interval::intervals:interval(), ChunkSize::pos_integer() | all)
  +        -> {intervals:interval(), db_as_list()}.
  +get_chunk(DB, Interval, ChunkSize) ->
  +    get_chunk_(DB, Interval, fun(_) -> true end, fun(E) -> E end, ChunkSize).
  +
  +%% @doc Returns all ValueFun(DBEntry) objects of the given DB which are in the
  +%%      given interval and satisfy FilterFun but at most ChunkSize elements.
  +%%      See get_chunk/3 for more details.
  +-spec get_chunk(DB::db(), Interval::intervals:interval(),
  +                FilterFun::fun((db_entry:entry()) -> boolean()),
  +                ValueFun::fun((db_entry:entry()) -> V), ChunkSize::pos_integer() | all)
  +        -> {intervals:interval(), [V]}.
  +get_chunk(DB, Interval, FilterFun, ValueFun, ChunkSize) ->
  +    get_chunk_(DB, Interval, FilterFun, ValueFun, ChunkSize).
  +
  +-spec get_chunk_(DB::db_t(), Interval::intervals:interval(),
  +                 FilterFun::fun((db_entry:entry()) -> boolean()),
  +                 ValueFun::fun((db_entry:entry()) -> V), ChunkSize::pos_integer() | all) ->
  +    {intervals:interval(), [V]}.
  +get_chunk_(DB, Interval, FilterFun, ValueFun, all) ->
  +    get_chunk_(DB, Interval, FilterFun, ValueFun, get_load_(DB));
  +get_chunk_({ETSDB, _Subscr} = DB, Interval, FilterFun, ValueFun, ChunkSize) ->
       % assert ChunkSize > 0, see ChunkSize type
       case get_load_(DB) of
           0 -> {intervals:empty(), []};
  
positive.code: -type db_t() :: {Table::tid() | atom(), SubscrTable::tid() | atom()}.
  
  % TODO: move these functions to the behaviour and implement them in the other DBs!
  -export([get_chunk/3, delete_chunk/3, get_split_key/4]).
  
  % Note: must include db_beh.hrl AFTER the type definitions for erlang < R13B04
  % to work.
  
negative.code:     Next = ETS_next(ETSDB, Current),
      get_split_key_inner(DB, Next, RealStart, TargetLoad - 1, Current, ETS_first, ETS_next).
  
  -spec delete_chunk(DB::db(), Interval::intervals:interval(), ChunkSize::pos_integer() | all)
          -> {intervals:interval(), db()}.
  delete_chunk(DB, Interval, ChunkSize) -> delete_chunk_(DB, Interval, ChunkSize).
  
  -spec delete_chunk_(DB::db_t(), Interval::intervals:interval(), ChunkSize::pos_integer() | all)
          -> {intervals:interval(), db_t()}.
  delete_chunk_(DB, Interval, ChunkSize) ->
      {Next, Chunk} = get_chunk_(DB, Interval, fun(_) -> true end, fun db_entry:get_key/1, ChunkSize),
      DB2 = lists:foldl(fun(Key, DB1) -> delete_entry_at_key(DB1, Key) end, DB, Chunk),
      {Next, DB2}.
  