anchor.diff:      end),
       {Tab, Ret}.
   
  -
  -%%
  -%%----- TESTS ------------------------------------------------
  -%%
  -
  --ifdef(TEST).
  -
  --include_lib("eunit/include/eunit.hrl").
  -
  --define(TABLES, lists:sort([atom_to_list(T) || T <- mnesia:system_info(tables) -- [schema]])).
  --define(FILENAMES(__M, __Dir), lists:sort([filename:rootname(filename:basename(F)) || F <- filelib:wildcard(__M, __Dir)])).
  --define(EMPTY_DIR(__Dir), [{F, file:delete(filename:absname(filename:join([__Dir,F])))} || F <- filelib:wildcard("*.*", __Dir)]).
  -
  -setup() ->
  -    application:load(imem),
  -    application:set_env(imem, mnesia_node_type, ram),
  -    {_, SnapDir} = application:get_env(imem, imem_snapshot_dir),
  -    imem:start(),
  -    _ = ?EMPTY_DIR(SnapDir),
  -    ?Log("after deleteing files ~p~n", [?FILENAMES("*.*", SnapDir)]).
  -
  -teardown(_) ->
  -    imem:stop().
  -
  -db_test_() ->
  -    {
  -        setup,
  -        fun setup/0,
  -        fun teardown/1,
  -        {with, [
  -            fun test_snapshot/1
  -        ]}}.
  -
  -test_snapshot(_) ->
  -    {_, SnapDir} = application:get_env(imem, imem_snapshot_dir),
  -    ?Log("snapshots :~n~p", [take([all])]),
  -    ?assertEqual(?TABLES, ?FILENAMES("*"++?BKP_EXTN, SnapDir)),
  -    _ = ?EMPTY_DIR(SnapDir),
  -    ?Log("snapshot tests completed!~n", []).
  -
  --endif.
  -
   %% ----- PRIVATE APIS ------------------------------------------------
   
   timestamp({Mega, Secs, Micro}) -> Mega*1000000000000 + Secs*1000000 + Micro.
  
positive.code:         , restore/5
          , zip/1
          , take/1
          ]).
  
  % gen_server callbacks
  
negative.code:     {ok,#state{snapdir=SnapshotDir}}.
  
  handle_info(imem_snap_loop, #state{snapFun=SFun,snapHash=SHash} = State) ->
      case ?GET_SNAPSHOT_CYCLE_WAIT of
          MCW when (is_integer(MCW) andalso (MCW >= 100)) ->
              {SnapHash,SnapFun} = case {?GET_SNAPSHOT_SCRIPT, ?GET_SNAPSHOT_SCRIPT_FUN} of
                  {false, _} ->       {undefined,undefined};
                  {true, <<"">>} ->   {undefined,undefined};
                  {true, SFunStr} ->
                      ?Debug("snapshot fun ~p", [SFunStr]),
                      case erlang:phash2(SFunStr) of
                          SHash   -> {SHash,SFun};
                          H1      -> {H1,imem_meta:compile_fun(SFunStr)}
                      end
              end,
              do_snapshot(SnapFun),
              erlang:send_after(MCW, self(), imem_snap_loop),
              {noreply, State#state{snapFun=SnapFun,snapHash=SnapHash}};
  