anchor.diff:                                  couch_views_actual_disk_size,
                                   couch_views_disk_size,
                                   couch_views_data_size,
  -                                per_ddoc_stats :: [per_ddoc_stats()]}).
  +                                couch_spatial_disk_size,
  +                                couch_spatial_data_size,
  +                                views_per_ddoc_stats :: [per_ddoc_stats()],
  +                                spatial_per_ddoc_stats :: [per_ddoc_stats()]}).
   
   
   %% API
  
positive.code:     #ns_server_couch_stats{couch_docs_actual_disk_size = DocsActualDiskSize,
                             couch_views_actual_disk_size = ViewsActualDiskSize,
                             couch_views_disk_size = ViewsDiskSize,
                             couch_views_data_size = ViewsDataSize} = CouchStats,
      [{couch_docs_actual_disk_size, DocsActualDiskSize},
       {couch_views_actual_disk_size, ViewsActualDiskSize},
       {couch_views_disk_size, ViewsDiskSize},
       {couch_views_data_size, ViewsDataSize}].
  
  parse_couch_stats(_TS, CouchStats, undefined = _LastTS, _, _) ->
      Basic = build_basic_couch_stats(CouchStats),
      {lists:sort([{couch_views_ops, 0.0} | Basic]), []};
  parse_couch_stats(TS, CouchStats, LastTS, LastViewsStats0, MinFileSize) ->
      BasicThings = build_basic_couch_stats(CouchStats),
      #ns_server_couch_stats{per_ddoc_stats = ViewStats} = CouchStats,
      LastViewsStats = case LastViewsStats0 of
                           undefined -> [];
                           _ -> LastViewsStats0
                       end,
      TSDelta = TS - LastTS,
      WithDiffedOps =
          case TSDelta > 0 of
              true ->
                  diff_view_accesses_loop(TSDelta, LastViewsStats, ViewStats);
              false ->
                  [{Sig, DiskS, DataS, 0} || {Sig, DiskS, DataS, _} <- ViewStats]
          end,
      AggregatedOps = lists:sum([Ops || {_, _, _, Ops} <- WithDiffedOps]),
      LL = [begin
                DiskKey = iolist_to_binary([<<"views/">>, Sig, <<"/disk_size">>]),
                DataKey = iolist_to_binary([<<"views/">>, Sig, <<"/data_size">>]),
                OpsKey = iolist_to_binary([<<"views/">>, Sig, <<"/accesses">>]),
                DataS = maybe_adjust_data_size(DataS0, DiskS, MinFileSize),
  
                [{DiskKey, DiskS},
                 {DataKey, DataS},
                 {OpsKey, OpsSec}]
            end || {Sig, DiskS, DataS0, OpsSec} <- WithDiffedOps],
      {lists:sort(lists:append([[{couch_views_ops, AggregatedOps}], BasicThings | LL])),
       ViewStats}.
  
  %% Tests
  
  basic_parse_couch_stats_test() ->
      CouchStatsRecord = #ns_server_couch_stats{couch_docs_actual_disk_size = 1,
                                                couch_views_actual_disk_size = 2,
                                                couch_views_disk_size = 5,
                                                couch_views_data_size = 6,
                                                per_ddoc_stats = [{<<"a">>, 8, 9, 10},
                                                                  {<<"b">>, 11, 12, 13}]},
      ExpectedOut1Pre = [{couch_docs_actual_disk_size, 1},
                         {couch_views_actual_disk_size, 2},
                         {couch_views_disk_size, 5},
                         {couch_views_data_size, 6},
                         {couch_views_ops, 0.0}]
          ++ [{<<"views/a/disk_size">>, 8},
              {<<"views/a/data_size">>, 9},
              {<<"views/a/accesses">>, 0.0},
              {<<"views/b/disk_size">>, 11},
              {<<"views/b/data_size">>, 12},
              {<<"views/b/accesses">>, 0.0}],
      ExpectedOut1 = lists:sort([{K, V} || {K, V} <- ExpectedOut1Pre,
                                           not is_binary(K)]),
      ExpectedOut2 = lists:sort(ExpectedOut1Pre),
  
negative.code:             ?log_debug("Get group info (~s/~s) failed:~n~p", [BinBucket, DDocId, Why])
      end.
  
  collect_view_stats(Mod, BinBucket, DDocIdList, MinFileSize) ->
      NameToStatsETS = ets:new(ok, []),
      try
          [views_collection_loop_iteration(Mod, BinBucket, NameToStatsETS, DDocId, MinFileSize)
           || DDocId <- DDocIdList],
          ets:tab2list(NameToStatsETS)
      after
  