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:     set_entry_(State, Entry).
  
  %% @doc Removes all values with the given entry's key from the DB.
  delete_entry_(State = {DB, _Subscr}, Entry) ->
      Key = db_entry:get_key(Entry),
      ets:delete(DB, Key),
      call_subscribers(State, {delete, Key}),
      State.
  
negative.code:                     {intervals:empty(), []};
                  FirstKey ->
                      %ct:pal("first key: ~.0p~n", [FirstKey]),
                      FirstEntry = get_entry_(DB, FirstKey),
                      Chunk0 = case FilterFun(FirstEntry) of
                                   true -> [ValueFun(FirstEntry)];
                                   _    -> []
                               end,
                      {Next, Chunk} =
                          get_chunk_inner(DB, ets:next(ETSDB, FirstKey), FirstKey,
                                          Interval, FilterFun, ValueFun, ChunkSize - 1, Chunk0),
                      case Next of
                          '$end_of_table' ->
                              {intervals:empty(), Chunk};
  