anchor.diff:  handle_call(_Request, _From, State) ->
       {reply, ok, State}.
   
  -handle_cast({update_ddoc, DDocId},
  +handle_cast({update_ddoc, DDocId, Deleted},
               #state{bucket=Bucket,
  -                   bucket_config=BucketConfig, map=Map} = State) ->
  -    maybe_define_group(Bucket, BucketConfig, DDocId, Map),
  -    {noreply, State};
  +                   bucket_config=BucketConfig,
  +                   ddocs=DDocs, map=Map} = State) ->
  +    State1 =
  +        case Deleted of
  +            false ->
  +                %% we need to redefine set view whenever document changes
  +                define_group(Bucket, BucketConfig, DDocId, Map),
  +                DDocs1 = sets:add_element(DDocId, DDocs),
  +                State#state{ddocs=DDocs1};
  +            true ->
  +                DDocs1 = sets:del_element(DDocId, DDocs),
  +                State#state{ddocs=DDocs1}
  +        end,
  +
  +    {noreply, State1};
   
   handle_cast(_Msg, State) ->
       {noreply, State}.
  
positive.code:                 vbucket_states,
                  master_db_watcher,
                  map,
                  pending_vbucket_states}).
  
  start_link(Bucket) ->
  
negative.code: 
      ?log_debug("Partitions to remove: ~p", [ToRemove]),
  
      sets:fold(
        fun (DDocId, _) ->
                apply_ddoc_map(Bucket, DDocId, Active, Passive, ToRemove)
        end, undefined, DDocs).
  
  get_vbucket_state(Bucket, VBucket) ->
      do_get_vbucket_state(list_to_binary(Bucket), VBucket).
  