anchor.diff:      list_to_tuple([stat_entry, TS | List]).
   
   
  -%% @doc Pass received stats to the archiver.
  -received(Pid, Stats) ->
  -    gen_server:cast(Pid, {stats, Stats}).
  +%% @doc Truncate the table if necessary.
  +maybe_truncate(#state{table=Tab, samples_since_truncate=?TRUNC_FREQ} = State) ->
  +    truncate(Tab, 60),
  +    State#state{samples_since_truncate=1};
  +maybe_truncate(#state{samples_since_truncate=N} = State) when N < ?TRUNC_FREQ ->
  +    State#state{samples_since_truncate=N+1}.
   
   
   %% @doc Convert a stat entry to a list of values.
  
positive.code:     {TS, L}.
  
  
  %% @doc Truncate a timestamp to a multiple of the given number of seconds.
  ts_trunc(Resolution, TS) ->
      {MegaSecs, Secs, _} = TS,
      MegaSecs * 1000000 + trunc(Secs / Resolution) * Resolution.
  
  
  %% @doc Generate a suitable name for the per-bucket gen_server.
  server(Bucket) ->
      list_to_atom(?MODULE_STRING ++ "-" ++ Bucket).
  
  %% @doc Generate a suitable name for the Mnesia table.
  table_name(Bucket) ->
      list_to_atom(lists:flatten(io_lib:format("~s-~s-~s", [?MODULE_STRING,
                                                            node(), Bucket]))).
  
negative.code: 
  -include_lib("eunit/include/eunit.hrl").
  
  -include("ns_common.hrl").
  -include("ns_stats.hrl").
  
  -behaviour(gen_server).
  
  -define(INIT_TIMEOUT, 5000).
  -define(TRUNC_FREQ, 10).
  
  -record(state, {bucket, table, samples_since_truncate = 1}).
  
  -export([start_link/1,
           latest/3, latest/4,
           latest_all/2, latest_all/3]).
  
  -export([code_change/3, init/1, handle_call/3, handle_cast/2, handle_info/2,
  