anchor.diff:  %% pre: Current is in ets table, ets table is not empty
   -spec get_chunk_inner(DB::db_t(), Current::?RT:key() | '$end_of_table',
                         RealStart::?RT:key(), Interval::intervals:interval(),
  -                      ChunkSize::pos_integer(), Chunk::db_as_list())
  -        -> {?RT:key() | '$end_of_table' | '$end_of_interval', db_as_list()}.
  -get_chunk_inner(_DB, RealStart, RealStart, _Interval, _ChunkSize, Chunk) ->
  +                      FilterFun::fun((db_entry:entry()) -> boolean()),
  +                      ValueFun::fun((db_entry:entry()) -> V),
  +                      ChunkSize::pos_integer(), Chunk::[V])
  +        -> {?RT:key() | '$end_of_table' | '$end_of_interval', [V]}.
  +get_chunk_inner(_DB, RealStart, RealStart, _Interval, _FilterFun, _ValueFun, _ChunkSize, Chunk) ->
       %ct:pal("inner: 0: ~p", [RealStart]),
       % we hit the start element, i.e. our whole data set has been traversed
       {'$end_of_interval', Chunk};
  -get_chunk_inner(_DB, Current, _RealStart, _Interval, 0, Chunk) ->
  +get_chunk_inner(_DB, Current, _RealStart, _Interval, _FilterFun, _ValueFun, 0, Chunk) ->
       %ct:pal("inner: 1: ~p", [Current]),
       % we hit the chunk size limit
       {Current, Chunk};
  -get_chunk_inner({ETSDB, _Subscr} = DB, '$end_of_table', RealStart, Interval, ChunkSize, Chunk) ->
  +get_chunk_inner({ETSDB, _Subscr} = DB, '$end_of_table', RealStart, Interval, FilterFun, ValueFun, ChunkSize, Chunk) ->
       %ct:pal("inner: 2: ~p", ['$end_of_table']),
       % reached end of table - start at beginning (may be a wrapping interval)
  -    get_chunk_inner(DB, ets:first(ETSDB), RealStart, Interval, ChunkSize, Chunk);
  -get_chunk_inner({ETSDB, _Subscr} = DB, Current, RealStart, Interval, ChunkSize, Chunk) ->
  +    get_chunk_inner(DB, ets:first(ETSDB), RealStart, Interval, FilterFun, ValueFun, ChunkSize, Chunk);
  +get_chunk_inner({ETSDB, _Subscr} = DB, Current, RealStart, Interval, FilterFun, ValueFun, ChunkSize, Chunk) ->
       %ct:pal("inner: 3: ~p", [Current]),
       case intervals:in(Current, Interval) of
           true ->
               Entry = get_entry_(DB, Current),
  +            Chunk1 = case FilterFun(Entry) of
  +                         true -> [ValueFun(Entry) | Chunk];
  +                         _    -> Chunk
  +                     end,
               Next = ets:next(ETSDB, Current),
  -            get_chunk_inner(DB, Next, RealStart, Interval, ChunkSize - 1, [Entry | Chunk]);
  +            get_chunk_inner(DB, Next, RealStart, Interval, FilterFun, ValueFun, ChunkSize - 1, Chunk1);
           _ ->
               {'$end_of_interval', Chunk}
       end.
  
positive.code: %%      ""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) ->
      % assert ChunkSize > 0, see ChunkSize type
      case get_load_(DB) of
          0 -> {intervals:empty(), []};
  
negative.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, get_chunk/5, delete_chunk/3, get_split_key/4]).
  
  % Note: must include db_beh.hrl AFTER the type definitions for erlang < R13B04
  % to work.
  