anchor.diff:  
   
   %% @doc Get the latest samples for a given interval from the archive
  -latest(minute, Node, Bucket) when is_atom(Node) ->
  -    [{Node, [Result]}] = latest(minute, [Node], Bucket),
  +latest(Period, Node, Bucket) when is_atom(Node) ->
  +    [{Node, [Result]}] = latest(Period, [Node], Bucket),
       Result;
  -latest(minute, Nodes, Bucket) when is_list(Nodes), is_list(Bucket) ->
  +latest(Period, Nodes, Bucket) when is_list(Nodes), is_list(Bucket) ->
       misc:pmap(fun (Node) ->
                         {Node, mnesia:transaction(
                                  fun () ->
  -                                       Tab = table_name(Node, Bucket),
  +                                       Tab = table_name(Node, Bucket, Period),
                                          Key = mnesia:last(Tab),
                                          mnesia:read(Tab, Key)
                                  end)}
                 end, Nodes, length(Nodes)).
   
   
  -latest(minute, Node, Bucket, N) when is_atom(Node), is_list(Bucket) ->
  -    [{Node, Results}] = latest(minute, [Node], Bucket, N),
  +latest(Period, Node, Bucket, N) when is_atom(Node), is_list(Bucket) ->
  +    [{Node, Results}] = latest(Period, [Node], Bucket, N),
       Results;
  -latest(minute, Nodes, Bucket, N) when is_list(Nodes), is_list(Bucket) ->
  +latest(Period, Nodes, Bucket, N) when is_list(Nodes), is_list(Bucket) ->
       misc:pmap(fun (Node) ->
  -                      {Node, walk(table_name(Node, Bucket), N)}
  +                      {Node, walk(table_name(Node, Bucket, Period), N)}
                 end, Nodes, length(Nodes)).
   
   
  -latest_all(minute, Bucket) ->
  -    latest(minute, ns_node_disco:nodes_wanted(), Bucket).
  -
  -
  -latest_all(minute, Bucket, N) ->
  -    latest(minute, ns_node_disco:nodes_wanted(), Bucket, N).
  +latest_all(Period, Bucket) ->
  +    latest(Period, ns_node_disco:nodes_wanted(), Bucket).
  +
  +
  +latest_all(Period, Bucket, N) ->
  +    latest(Period, ns_node_disco:nodes_wanted(), Bucket, N).
   
   
   %%
  
positive.code:     unhandled.
  
  
  handle_info({stats, Bucket, Sample}, State = #state{bucket=Bucket, table=Tab}) ->
      {atomic, ok} = mnesia:transaction(fun () -> mnesia:write(Tab, Sample, write) end),
      gen_event:notify(ns_stats_event, {sample_archived, Bucket, Sample}),
      {noreply, maybe_truncate(State)};
  
negative.code:     list_to_stat(TS, Avgs).
  
  
  create_tables(Bucket) ->
      Node = node(),
      ?log_info("Creating tables for bucket ~p if they don't already exist.",
                [Bucket]),
      lists:foreach(
        fun ({Period, _, _}) ->
                TableName = table_name(Node, Bucket, Period),
                case mnesia:create_table(TableName,
                                         [{disc_copies, [Node]},
                                          {record_name, stat_entry},
                                          {type, ordered_set},
                                          {attributes,
                                           record_info(fields, stat_entry)}]) of
                    {atomic, ok} ->
                        ?log_info("Created table for bucket ~p.", [Bucket]);
                    {aborted, {already_exists, _}} ->
                        ?log_info("Table already existed for bucket ~p.",
                                  [Bucket])
                end
        end, archives()).
  
  
  %% @doc Convert a list of values from stat_to_list back to a stat entry.
  