anchor.diff:      doc_options,
       conflicts,
       timeout,
  -    timeout_fun
  +    timeout_fun,
  +    aggregation_kvs,
  +    aggregation_results
   }).
   
   handle_db_changes(Args, Req, Db) ->
  
positive.code: 
  
  
  changes_row(Results, DocInfo, #changes_acc{filter={fast_view,_,_,_}}=Acc) ->
      format_doc_info_change(Results, DocInfo, Acc);
  changes_row(Results, KV, #changes_acc{view=#mrview{}}=Acc) ->
      {{Seq, Key}, {Id, Value, Rev}} = KV,
      {[{<<"seq">>, Seq}, {<<"id">>, Id}, {<<"key">>, Key}, {<<"value">>, Value}, {<<"changes">>, Results}] ++ maybe_get_changes_doc({Id, Rev}, Acc)};
  changes_row(Results, #doc_info{}=DocInfo, Acc) ->
      format_doc_info_change(Results, DocInfo, Acc).
  
  format_doc_info_change(Results, #doc_info{}=DocInfo, Acc) ->
      #doc_info{
          id = Id, high_seq = Seq, revs = [#rev_info{deleted = Del} | _]
      } = DocInfo,
  
negative.code:         filter = Filter,
          view = View
      } = Acc,
      DbEnumFun = fun changes_enumerator/2,
      case can_optimize(FirstRound, Filter) of
          {true, Fun} ->
              Fun(Db, StartSeq, Dir, DbEnumFun, Acc, Filter);
          _ ->
              case {View, Filter}  of
                  {#mrview{}, {fast_view, _, _, _}} ->
                      couch_mrview:view_changes_since(View, StartSeq, DbEnumFun, [{dir, Dir}], Acc);
                  {undefined, _} ->
                      couch_db:changes_since(Db, StartSeq, DbEnumFun, [{dir, Dir}], Acc);
                  {#mrview{}, _} ->
                      ViewEnumFun = fun view_changes_enumerator/2,
                      {Go, Acc0} = couch_mrview:view_changes_since(View, StartSeq, ViewEnumFun, [{dir, Dir}], Acc),
                      case Acc0 of
                          #changes_acc{aggregation_results=[]} ->
                              {Go, Acc0};
                          _ ->
                              #changes_acc{
                                  aggregation_results = AggResults,
                                  aggregation_kvs = AggKVs,
                                  user_acc = UserAcc,
                                  callback = Callback,
                                  resp_type = ResponseType,
                                  prepend = Prepend
                              } = Acc0,
                              ChangesRow = view_changes_row(AggResults, AggKVs, Acc0),
                              UserAcc0 = Callback({change, ChangesRow, Prepend}, ResponseType, UserAcc),
                              reset_heartbeat(),
                              {Go, Acc0#changes_acc{user_acc=UserAcc0}}
                      end
              end
      end.
  
  