anchor.diff:              ok
       end.
   
  -apply_map(Bucket, DDocs, OldMap, NewMap) ->
  +apply_map(Bucket, DDocs, OldMap, NewMap, UseReplicaIndex) ->
       ?views_info("Applying map to bucket ~s:~n~p", [Bucket, NewMap]),
   
       {Active, Passive, Cleanup, Replica, ReplicaCleanup} =
  
positive.code:                 map,
                  ddocs,
                  pending_vbucket_states,
                  waiters}).
  
  -define(csv_call(Call, Args),
          %% hack to not introduce any variables in the caller environment
  
negative.code:         ok = ?csv_call(set_partition_states,
                         [SetName, DDocId, Active, Passive, Cleanup]),
  
          case UseReplicaIndex of
              true ->
                  ok = ?csv_call(add_replica_partitions,
                                 [SetName, DDocId, Replica]),
                  ok = ?csv_call(remove_replica_partitions,
                                 [SetName, DDocId, ReplicaCleanup]);
              false ->
                  ok
          end
  
      catch
          throw:{not_found, deleted} ->
              %% The document has been deleted but we still think it's
  